Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
A DVD can hold about 4.4GB. I want to store almost that much in a DVD, and I want everything to be encrypted.
What I tried:
- create a 4.4GB loopback file;
- loop-mount it (losetup) and create a partition table with one partition in it;
- format the one partition with crypt/LUKS;
- open the crypt/LUKS partition and create a file system in it.
Everything worked fine except that I ended up with only 3.9GB available for storage. I find that overhead too high.
Where are you losing the space ?
- container ?
- filesystem ?
- GB vs GiB ? (look it up in need).
Given no relevant info, I'd guess you are using ext3/4 and the default 5% reserved blocks is in effect. For data (non-system) filesystems it can be safely set to zero using tune2fs.
If you formatted your loopback partition ext4, you lost 5% right off the bat. An ext4 format reserves 5% of the disk space for maintenance and other reasons by default. There are ways around that or you can just format to xfs instead.
4.3GB, More like 4.28 to be safe. But I guess that depends on if you measure it base 2, 8, or 10. Also if you are talking about Gigabyte or Gibibyte. A DVD also has a lead in and lead out that takes up space. Also depends on if the file system is iso9660 or UDF.
Quote:
Everything worked fine except that I ended up with only 3.9GB available for storage.
The loopback file is just a container. The filesystem has overhead i.e. metadata as well as luks in addition to reserved space. You can reduce reserved space to zero and different filesystems have different overhead but it will never be zero.
ext4 metadata is around 3% and xfs is around 2% so changing will let you store more data but it will never be 4.4 GB.
However, what are you using for a filesystem? Maybe try UDF.
Answering multiple comments above, the DVD burning application tells me that I can store up to 4,482 MB and I have burned DVDs with up to 4,470 MB before. So in a "bare" burning procedure, 4,400 is very reasonable and possible.
About the file system, I used Btrfs. I've had hard disk partitions formatted with ext2, ext3, ext4, xfs and btrfs, and that last one seems to be the most efficient in space use. I will try again with explicit metadata allocation, probably 1%, or maybe I can remove journaling altogether? It's a DVD, a frozen filesystem, so journaling is useless and wasteful. I hadn't thought about the journaling aspect. My bad. Thank you for the pointers.
Or maybe I could use some other encryption method, but I am only familiar with crypt/LUKS.
By definition a single layer DVD is 4.7 GB or 4.38 GiB. If the DVD burning application was using MB versus MiB 4,482 would be reasonable.
Just to see I created a 4.4 GiB image file via fallocate, luks container with a xfs filesystem which is supposed to be close to btrfs in overhead and the df results were 4367904 and df -h 4.2GB.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.