Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 122421 - genkernel initrd luks support
Summary: genkernel initrd luks support
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: InVCS
: 123305 135924 142365 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-02-10 16:59 UTC by Cláudio Valente
Modified: 2006-07-31 22:23 UTC (History)
6 users (show)

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


Attachments
patch for genkernel to allow initrd to use luks encrypted devices (genkernel-luks-patch.diff,10.83 KB, patch)
2006-02-10 17:00 UTC, Cláudio Valente
Details | Diff
new improved patch (genkernel-luks-patch-2.diff,10.59 KB, patch)
2006-02-12 10:58 UTC, Cláudio Valente
Details | Diff
recursive (genkernel-luks-patch-3.diff,13.18 KB, patch)
2006-02-13 08:59 UTC, Cláudio Valente
Details | Diff
md fix (122421-fix-md.patch,947 bytes, patch)
2006-03-21 11:17 UTC, Tim Yamin (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cláudio Valente 2006-02-10 16:59:50 UTC
Hi.

I just tried to get my system booting from a luks encrypted root partition and found that the information at http://gentoo-wiki.com/SECURITY_System_Encryption_DM-Crypt_with_LUKS regarding creating the init rd is extremely complicated and that the custum ebuild provided by the luks author (http://luks.endorphin.org/gentoo) is very outdated, not supporting udev for instance.

I have thus made a patch for genkernel based on the ebuild provided by the luks author.

you can find it attached.

The only non automated point is building the static version of cryptsetup. For now I suppose it's under /bin/cryptsetup-static.
Maybe cryptsetup-luks could have a static use flag

The patch is for the 3.3.10 version
Do what you want with it.
Maybe someone will find it usefull.

TIA
Comment 1 Cláudio Valente 2006-02-10 17:00:51 UTC
Created attachment 79476 [details, diff]
patch for genkernel to allow initrd to use luks encrypted devices
Comment 2 Cláudio Valente 2006-02-12 10:55:45 UTC
Turns out cryptsetup-luks allready has "dynamic" flag wich by default is set to false resulting in a static binary.

I have updated my patch accordingly, solved other bugs (LUKS="yes/no" on /etc/genkernel now works) and added a little explanation in the comandline help
Comment 3 Cláudio Valente 2006-02-12 10:58:47 UTC
Created attachment 79580 [details, diff]
new improved patch

other things that could be done.

* Load copy some necessary modules to the initrd and load them at boot (not essential)
* blue-sky scenario: use luksDump to check what modules the partition needs and load them automatically
Comment 4 Tim Yamin (RETIRED) gentoo-dev 2006-02-12 11:45:21 UTC
I'd imagine your patch changes something in generic/, right? Want to rerun diff with -ur so the changes in there get diffed as well? Thanks.
Comment 5 Cláudio Valente 2006-02-13 08:59:12 UTC
Created attachment 79704 [details, diff]
recursive

Sorry about forgetting to recurse.

Yes it changes files is generic (linuxrc for sure)

I also added the author information regarding this file because it is copy paste from the luks' creator ebuild.

Other files should be independent work by me.

This is pretty simple stuff but I think it would be a nice addition to genkernel and with a small effort.

New patch created
Comment 6 Jakub Moc (RETIRED) gentoo-dev 2006-02-18 11:15:55 UTC
*** Bug 123305 has been marked as a duplicate of this bug. ***
Comment 7 Clemens Fruhwirth 2006-02-18 11:35:17 UTC
Sorry for dup. I checked few days ago and there was no such request. I didn't bother to check again after I found a time slice to diff it. Sorry for noise. Although I wonder why Claudio didn't mail me about that.

However, go ahead with his patch. He seemed to have spent more effort on
that patch than me.
Comment 8 Cláudio Valente 2006-02-20 08:50:12 UTC
(In reply to comment #7)
...
> However, go ahead with his patch. He seemed to have spent more effort on
> that patch than me.
> 

I don't think thats very accurate. Like I wrote on my first comment, this is mainly an adaptation of your patch and by no way do I wish to claim authorship of work that isn't my own.

By the way, thanks for LUKS!

I also have a preliminary version that uses luksDump to see the ciphers it needs to mount the device and loads them on the fly from the initrd (if not statically compiled).

I run away from bash as much as I can so I probably have something very wrong, because while trying it on a running system it seems to work but when I boot, apparently ciphers don't get detected. This is probably some stupid mistake I made or some feature I use that behaves differently on busybox.

This is not very important, but if anyone is interested I can push it harder or give the code I have written. The only great advantage would be not having to compile the crypto-stuff and dm-stuff statically into the kernel. I guess for novices that may turn out to be unnecessarily complex.

A check to see if cryptsetup is static would be nice at initrd build time.
Comment 9 Clemens Fruhwirth 2006-02-20 09:47:15 UTC
You will find a static check in my patch. You might want to put it into a helper file that is sourced by gen_initrd.sh and gen_initram.sh.

Today I migrated to LUKS on raid and noticed that there is a kernel problem that is worked around in genkernel successfully. The workaround must be enabled for LUKS too though.

Just add 
setup_md_device ${LUKSdev}
after the LUKSdev is set in linuxrc. This works fine for me.
Comment 10 Clemens Fruhwirth 2006-03-21 09:58:34 UTC
One month of no activity. Maintainers, any difficulties?
Comment 11 Chris Gianelloni (RETIRED) gentoo-dev 2006-03-21 11:11:55 UTC
Well, we are currently busy fixing bugs, rather than working on new support.  Honestly actual problem reports always take precedence over feature requests, so this might not even be considered for a little while as we try to work out some of the issues we have with genkernel 3.3.11 that actually affect the release.  After those bugs are worked out, then we will revisit this.  The simple answer is "when we get to it".  Asking doesn't speed up the process.  ;]
Comment 12 Tim Yamin (RETIRED) gentoo-dev 2006-03-21 11:17:49 UTC
Created attachment 82798 [details, diff]
md fix

Patch looks good, and the demand for it seems to be there so I see no problem with putting it into 3.3. However, the patch needs to be able to deal with setup_md_devices correctly -- can you test this works without having to manually run setup_md_device please?

Thanks.
Comment 13 Craig Andrews gentoo-dev 2006-04-14 13:39:52 UTC
Any news on this? It's been another month :-)
Comment 14 Tim Yamin (RETIRED) gentoo-dev 2006-04-14 14:20:02 UTC
(In reply to comment #13)
> Any news on this? It's been another month :-)

Yes, can somebody check the patch in comment #12 works please?
Comment 15 Chris Gianelloni (RETIRED) gentoo-dev 2006-06-09 07:25:44 UTC
I've added a modified version of the patch above, plus the md fix, plus the is_static function from the other bug to CVS.  If it doesn't work, I'm sure we'll find out soon enough... ;]
Comment 16 Cláudio Valente 2006-06-09 07:39:52 UTC
(In reply to comment #15)

> If it doesn't work, I'm sure
> we'll find out soon enough... ;]

Post problems here. Maybe we can be of some assistance if that happens...
Comment 17 Tim Yamin (RETIRED) gentoo-dev 2006-06-10 05:15:24 UTC
*** Bug 135924 has been marked as a duplicate of this bug. ***
Comment 18 Tim Yamin (RETIRED) gentoo-dev 2006-06-20 12:53:25 UTC
Fixed in 3.4.0_pre1, thanks. Let us know if things break :)
Comment 19 Jakub Moc (RETIRED) gentoo-dev 2006-07-31 22:23:58 UTC
*** Bug 142365 has been marked as a duplicate of this bug. ***