Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 73598 - [PATCH] support for loops in dm-crypt
Summary: [PATCH] support for loops in dm-crypt
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-06 15:39 UTC by Dylan Carlson (RETIRED)
Modified: 2005-01-31 06:34 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
rc-scripts-1.6.7 patch v1 (rc-scripts-1.6.7-dmcrypt_loops.diff,4.24 KB, patch)
2004-12-06 15:41 UTC, Dylan Carlson (RETIRED)
Details | Diff
rc-scripts-1.6.7 patch v2 (rc-scripts-1.6.7-dmcrypt_loops.diff,4.23 KB, patch)
2004-12-07 08:21 UTC, Dylan Carlson (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dylan Carlson (RETIRED) gentoo-dev 2004-12-06 15:39:29 UTC
This patch allows dm-crypt to create loop mappings in conf.d/cryptfs.  

1.  Create a file, encrypt it, mkfs, mount, e.g.
   # dd if=/dev/zero of=/mnt/crypt/home bs=1024 count=20000000
   (20 gig file)
   # losetup /dev/loop0 /mnt/crypt/home
   # cryptsetup -y -c serpent -s 256 create home-crypt /dev/loop0
   (create/enter password)
   # mkfs.xfs /dev/mapper/home-crypt
   # mount -o rw,noatime,nodev,nosuid,quota /dev/mapper/home-crypt /home
   (test it)
   # umount /home
   (add fstab entry)
   /dev/mapper/home-crypt  /home  xfs  noatime,nodev,nosuid,quota,rw   0 2

2. Add to conf.d/cryptfs.  This is pretty much like any other mount, with one extra setting (loop_file=).  e.g.,

   mount='home-crypt'
   source='/dev/loop0'
   options='-c serpent -s 256'
   loop_file='/mnt/crypt/home'

3. Assuming the file was set up correctly in the first place, the scripts will handle the rest.  Specifically:

   - checkfs was modified to parse for loop_file and set up the loop device(s).
   - localmount was modified so that it doesn't complain about loop_file syntax.
   - halt.sh was modified to remove the loops after taking down the dm-crypt maps.
   - conf.d/cryptfs was modified with comments to show an example loop mount.
Comment 1 Dylan Carlson (RETIRED) gentoo-dev 2004-12-06 15:41:12 UTC
Created attachment 45403 [details, diff]
rc-scripts-1.6.7 patch v1
Comment 2 rob holland (RETIRED) gentoo-dev 2004-12-07 02:14:21 UTC
I'm not interested in testing this. I can't see why people would use a loopback filesystem under a dm-crypt mapping. However, from my brief scan of the patch it looks fine to me if that counts for anything.

I'd really like a note adding to the example config that there is no requirement to use any loop mounts at all to make use of dm-crypt.
Comment 3 Dylan Carlson (RETIRED) gentoo-dev 2004-12-07 05:43:45 UTC
You can't see why someone would use a loop under dm-crypt?  

1.  someone needs to encrypt parts of an existing filesystem, and
2.  can't fdisk for whatever reason and just use a raw device

perhaps most importantly,

3.  cryptoloop has been broken/unmaintained since 2.6.8.

I use dm-crypt both ways, and believe it is intuitively obvious that you don't have to use loops to use dm-crypt.  Anyone who has gotten far enough along to be configuring conf.d/cryptfs has used cryptsetup, so we don't need to spell it out for them.
Comment 4 Dylan Carlson (RETIRED) gentoo-dev 2004-12-07 08:21:58 UTC
Created attachment 45440 [details, diff]
rc-scripts-1.6.7 patch v2

fix to typo in localmount
Comment 5 SpanKY gentoo-dev 2005-01-30 14:01:28 UTC
now in cvs, thanks guys
Comment 6 Mike Auty (RETIRED) gentoo-dev 2005-01-30 15:41:46 UTC
Hi, I noticed but forgot to mention (and tell me if this should be another bug, because I'll open it), that this setup won't help with loopback files not stored on root.  Since mounting/setup of the systems is done during the checkfs phase, a directory such as /home may not have been mounted.  If there's a loopback filesystem on there, then at boot time it won't be found and won't be automatically mounted.  After it gets to the localmount section it doesn't actually do any mounting...

I don't entirely know how to fix this, since it may be that some loopback systems contain other areas to be mounted.  It looks like it may need some kind of sort to figure out the order to mount everything in.  Anyway, for the time being at least, loopback systems must be stored on a device that is already mounted by the time checkfs runs...

Hope this is of some help, even though it's a bit late...

Mike  5:)
Comment 7 Dylan Carlson (RETIRED) gentoo-dev 2005-01-31 06:34:13 UTC
m.auty:  Yeah, that will need to be a new bug (enhancement) to address those other use cases.  I will be happy to test it if you work up a patch.

vapier: cheers