LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 07-09-2022, 08:01 PM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,434

Rep: Reputation: 110Reputation: 110
How to store files in an encrypted DVD?


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.

Is there a better way?

TIA
 
Old 07-09-2022, 11:38 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,147

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
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.
 
Old 07-10-2022, 09:49 AM   #3
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,988

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
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.
 
1 members found this post helpful.
Old 07-10-2022, 10:16 AM   #4
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,147
Blog Entries: 6

Rep: Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834
Quote:
A DVD can hold about 4.4GB.
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.
Probably what you are going to get.

And what the others have said.
 
Old 07-10-2022, 10:22 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,770

Rep: Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933
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.

https://www.frederickding.com/posts/...-guide-273316/

Last edited by michaelk; 07-10-2022 at 11:14 AM.
 
1 members found this post helpful.
Old 07-10-2022, 04:38 PM   #6
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,434

Original Poster
Rep: Reputation: 110Reputation: 110
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.

Last edited by lucmove; 07-10-2022 at 04:43 PM.
 
Old 07-10-2022, 07:01 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,770

Rep: Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933Reputation: 5933
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.

Last edited by michaelk; 07-10-2022 at 07:12 PM.
 
Old 07-11-2022, 02:37 PM   #8
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,434

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by michaelk View Post
I followed those instructions and they worked pretty well for the most part. I just couldn't use UDF.

Code:
mkudffs: Error: Not enough blocks on device '/dev/mapper/encdvd', try decreasing blocksize
'man mkudffs' gives me four options for blocksize and all of them resulted in the same error. Shrug.

So I used XFS with a measly 76MB overhead and I could store almost 4.4GB of data.

Then I mounted and tested the DVD and it works.

It's solved. Many thanks again.

Last edited by lucmove; 07-11-2022 at 02:40 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Flathub vs. Snap Store: Which App Store Should You Use? LXer Syndicated Linux News 5 09-20-2019 01:08 PM
LXer: Store Files In An Encrypted Image LXer Syndicated Linux News 0 02-05-2018 02:03 PM
vSphere / ESXi - Renaming Directory Names in Data-Store and Moving things around in Data-Store devUnix Linux - Virtualization and Cloud 1 04-27-2017 08:13 AM
Information store: What software could I use to store and access various info merixon Linux - Software 2 12-17-2008 11:51 AM
'alsactrl store' doesn't seem to store... endfx Slackware 1 08-20-2004 01:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration