LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-26-2015, 08:29 PM   #1
michaelslack
Member
 
Registered: Feb 2013
Location: Sydney
Distribution: slackware
Posts: 110

Rep: Reputation: 36
Can mkinitrd unlock an encrypted device identified by uuid?


Dear slackers,

For a year or so now (well, since the release of 14.1 I guess) I have had my main work system as slackware 14.1 on a portable usb 3.0 drive. Since it's easy to lose this it is encrypted according to the section "Combining LUKS and LVM" on README_CRYPT.TXT from the top directory of the slackware tree.

A few extra things were needed which are summarised in the mkinitrd command I used:

Code:
mkinitrd -c -k 3.10.17-smp -f ext4 -r /dev/cryptvg/root -m hid_generic:usb-storage:xhci-hcd:ehci-hcd:ehci-pci:ext4:hid-logitech-dj:hid-microsoft:uhci-hcd:usbhid -C /dev/sdb2 -w 5 -h /dev/cryptvg/swap -L -u -o /boot/initrd-5sec.gz
I've included extra modules there for usb keyboards so I can enter the passphrase etc. But the thing I'm mainly concerned with is the

Code:
-C /dev/sdb2
part. That's what tells it to unlock /dev/sdb2 using cryptsetup so the root filesystem can be accessed.

This works fine, although luckily all the machines I boot it with only have a single disk, so the usb disk is always allocated /dev/sdb.

What I would *ideally* like to do is refer to the disk by its uuid instead of /dev/sdb. However I haven't been able to work out how to do this. There are various threads discussing doing this with an unencrypted usb disk (by adding things to /etc/fstab) but in the encrypted case I believe it has to happen at this stage.

It was a while ago since I tried this, but from memory one problem was that in the initrd filesystem there was no /dev/disk/by-uuid (although from memory I think there was /dev/disk/by-label, although the funny characters in the labels disagreed with mkinitrd I think); this I found out by exploring at the prompt that was offered during boot when the root filesystem couldn't be found. I tried putting a larger -w value on the mkinitrd command line but it was never populated no matter how long I asked it to wait.

A workaround is to create a different initrd for each possibility (sdb,sdc,sdd, etc) and then (hopefully) select the right one at the boot screen. However it would be nicer to use uuid (my current motivation is that I've just ordered a machine with 4 disks).

Does anyone know if this is (or isn't) possible?

Many thanks,

Michael

Last edited by michaelslack; 03-26-2015 at 11:18 PM.
 
Old 03-27-2015, 06:04 AM   #2
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,901

Rep: Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025
Don't know whether the patches resulting from this discussion still apply, but for what it's worth...

http://www.linuxquestions.org/questi...4/#post4629119

It seemed like a good idea to me, don't know why it was never adopted into slackware propper.
 
Old 03-27-2015, 04:26 PM   #3
michaelslack
Member
 
Registered: Feb 2013
Location: Sydney
Distribution: slackware
Posts: 110

Original Poster
Rep: Reputation: 36
Thanks GazL, that thread certainly discusses the exact same issue. It would certainly be a good idea to add that capability.

Another possibility comes to mind. In the README_CRYPT.TXT it also mentions the possibility of compiling a kernel with all the desired capabilities "built in" (i.e. not added as modules). This would avoid the need to use an initrd in the first place. I wonder though how does the kernel go about unlocking the correct device? Does it just scan all available devices? How is lilo then configured?

Cheers,

Michael
 
Old 03-28-2015, 06:01 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,901

Rep: Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025Reputation: 5025
To the best of my knowledge, it doesn't. You can build the necessary modules into the kernel for encryption to work without having to include the modules in the initrd, but if you have an encrypted root filesystem, or a rootfs on lvm, you're still going to need an initrd to run cryptsetup and/or vgscan/vgchange -ay to make it accessible during boot.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
encrypted second partition needing more than 1 key to unlock AnalBeard Linux - Server 2 04-13-2014 03:34 AM
Slackware 14.1: LUKS encrypted volumes + mkinitrd => missing dmsetup and can't unlock furryspider Slackware 4 11-16-2013 09:58 AM
[SOLVED] Unlock LUKS encrypted partition with USB drive yenn Slackware 4 02-26-2013 04:39 PM
[SOLVED] How to mount by-uuid if the device won't show in /dev/disk/by-uuid untill after blkid /dev/sd* ? masmddr Linux - General 4 01-10-2011 07:38 PM
[SOLVED] No /lib/modules/2.6.33.4-smp .. for mkinitrd - encrypted installation hua Slackware 5 07-22-2010 09:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:35 AM.

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