LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation
User Name
Password
Slackware - Installation This forum is for the discussion of installation issues with Slackware.

Notices



Reply
 
Search this Thread
Old 03-17-2012, 09:42 AM   #1
johnbristol
LQ Newbie
 
Registered: Feb 2008
Posts: 12

Rep: Reputation: 2
UUID= syntax not recognized by cryptsetup in initrd LUKSDEV


slackware-13.37.

What I'm trying to do is create a USB flash drive which can boot regardless of the drive letter it's assigned.

The tty copy below shows that during a boot, cryptsetup isLuks says yes to "cryptsetup isLuks /dev/sdb3" but the same test fails if UUID= syntax is used.

/ # cryptsetup isLuks UUID="fa649b04-5ede-496f-9168-331161a2b833"
Device UUID=fa649b04-5ede-496f-9168-331161a2b833 doesn't exist or access denied

but that's the right UUID for the same /dev/sdb3. I can't use /dev/disk/by-uuid/foo because there's no /dev/disk at that stage of the boot.

Changing the mkinitrd -C from UUID=foo to /dev/sdb3 gives me a working boot stick but only if the drive's /dev/sdb.

I upgraded my 13.37 cryptsetup on the stick from 1.2.0 to 1.4.1 but that didn't change anything.

Is there a module I need to load to enable that syntax recognition, perhaps?




tty log:
Code:
[    6.724952]  sdb: sdb1 sdb2 sdb3
[    6.727918] sd 6:0:0:0 [sdb] Assuming drive cache: write through
[    6.729488] sd 6:0:0:0 [sdb] Attaching SCSI removable disk
/boot/initrd.gz:  Loading 'uk' keyboard mapping:
>>> Using LUKS key file: 'LABEL=xfer:/originalpassword.luks'
  No volume groups found
  LUKS device 'UUID=fa649b04-5ede-496f-9168-331161a2b833' unavailable for unlocking!
  mount: mounting /dev/fdv/root on /mnt failed: No such file or directory
  ERROR:  No /sbin/init found on rootdev (or not mounted).  Trouble ahead.
          You can try to fix it. Type 'exit' when things are done.
 
/bin/sh: can't access tty; job control turned off
/ # blkid
/dev/sdb3: UUID="fa649b04-5ede-496f-9168-331161a2b833"
/dev/sdb2: LABEL="boot" UUID="895e3a22-1513-4fda-b7b4-5e2b67b8cac2" 
/dev/sdb1: LABEL="xfer" UUID="A5FD-1205"
/dev/sda1: UUID="358ea3e5-36cc-4db2-8894-94a84f281b8c" 
/ # cryptsetup isLuks /dev/sdb3
/ # cryptsetup isLuks UUID="fa649b04-5ede-496f-9168-331161a2b833" 
Device UUID=fa649b04-5ede-496f-9168-331161a2b833 doesn't exist or access denied
/ # cryptsetup isLuks /dev/disk/bu-uuid/fa649b04-5ede-496f-9168-331161a2b833
Device /dev/disk/bu-uuid/fa649b04-5ede-496f-9168-331161a2b833 doesn't exist or access denied
 
Old 03-17-2012, 11:07 AM   #2
johnbristol
LQ Newbie
 
Registered: Feb 2008
Posts: 12

Original Poster
Rep: Reputation: 2
http://pastebin.com/vKzYGbHL is a script to create the bootable stick, as far as I've got it. It's been working fine to create a stick that will come up if it's allocated /dev/sdb, or one that will come up if it's allocated /dev/sdc, but the right answer is to eliminate the drive letters and recognize the drive directly. I'm going to have to auto-edit /etc/fstab as well, when I get that far.

I have it in mind that I'm moving a step beyond people showing each other their desktop as a graphic, toward giving each other a full installation. And it makes a pretty good hot backup too.

As for fixing my problem, I've read http://www.bluelife.at/blog/articles..._on_USB_Stick/ twice and I expect it's the way to do it but I've not understood what I've read so far. I'll try again.

Last edited by johnbristol; 03-17-2012 at 12:50 PM.
 
Old 03-17-2012, 04:10 PM   #3
johnbristol
LQ Newbie
 
Registered: Feb 2008
Posts: 12

Original Poster
Rep: Reputation: 2
From reading the blog I referenced earlier, I think the init script in mkinitrd needs to treat LUKSDEV the same as ROOTDEV's treated here:
Code:
    luksdev=/dev/*)
      LUKSDEV=$(echo $ARG | cut -f2 -d=)
    ;;

    root=/dev/*)
      ROOTDEV=$(echo $ARG | cut -f2 -d=)
    ;;
    root=LABEL=*)
      ROOTDEV=$(echo $ARG | cut -f2- -d=)
    ;;
    root=UUID=*)
      ROOTDEV=$(echo $ARG | cut -f2- -d=)
    ;;
and to use blkid -U to convert UUID= to /dev/sdxx for each LUKSDEV here, so that the /dev/sdxx format is either used here or in the deferred bit later.
Code:
    LUKSLIST_DEFERRED=""
    LUKSLIST=$(echo $LUKSDEV | tr -s ':' ' ')
    for LUKSDEV in $LUKSLIST ; do
I've not looked at the /etc/rc.d/rc.6 script yet, I'm feeling uncomfortably out of my depth at the moment.

Last edited by johnbristol; 03-17-2012 at 05:07 PM. Reason: use blkid instead of having to add findfs to initrd
 
Old 03-20-2012, 01:55 AM   #4
elfenlied
Member
 
Registered: Dec 2004
Posts: 83

Rep: Reputation: 8
What does your fstab look like? Also is your luks encrypted disk showing up in /dev/mapper?

I have been playing around with luks encrypted volumes today and this is what my /etc/fstab looks like, mind you I'm using centos.

Code:
#
# /etc/fstab
# Created by anaconda on Fri Mar  2 22:01:06 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=4b93c7d4-6c92-494e-a076-4c897b3df7b5 /                       ext4    defaults        1 1
UUID=3159a2d8-7efd-469b-a196-dd6477ba816e /boot                   ext4    defaults        1 2
UUID=8f944bbb-37e1-4a03-a7fc-8e73faca25a3 /home                   ext4    defaults        1 2
UUID=30c6ddb4-47d4-4f0f-be97-04bf380f52dc swap                    swap    defaults        0 0
UUID=9b06c71e-3dda-4223-a729-0c24db4bdda0 /mnt/crypt		  ext4	  defaults	  1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
So from that I'm not hard coding any device names so I am going to assume that it will work regardless of what the system decides the device names for those drives will be, I could probably test it on a usb key tonight to verify.

Also on centos my /etc/crypttab looks like this:

Code:
mntcrypt /dev/disk/by-uuid/bf2e807f-fe92-461b-9cde-a19fdd38e034 none
I think I might have the same issue you're having with the crypttab but I'll see if I can setup a test install on a USB key and verify.

Last edited by elfenlied; 03-20-2012 at 02:00 AM.
 
Old 03-20-2012, 01:39 PM   #5
johnbristol
LQ Newbie
 
Registered: Feb 2008
Posts: 12

Original Poster
Rep: Reputation: 2
I ought to have looked before I wrote that about fstab - you're quite right, it has no specific references:
Code:
/dev/jhv/swap    swap             swap        defaults         0   0
/dev/jhv/root    /                ext4        defaults         1   1
/dev/jhv/home    /home            ext4        defaults         1   2
#/dev/cdrom      /mnt/cdrom       auto        noauto,owner,ro  0   0
/dev/fd0         /mnt/floppy      auto        noauto,owner     0   0
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0
tmpfs            /dev/shm         tmpfs       defaults         0   0
Slackware gets by without a /etc/crypttab. The issue I'm patching is way back in the bootstrap process where the initrd is at work. Cryptsetup doesn't know UUID= and udev hasn't started so there's no /dev/disk/ so the only way is to put something like a blkid call before the cryptsetup stage to feed it the runtime /dev/sdxx for whatever LVM volumes need opening.

When I've got it tested I'll add it to the thread, there's been days with no spare hours since I started it.
 
Old 03-20-2012, 06:10 PM   #6
elfenlied
Member
 
Registered: Dec 2004
Posts: 83

Rep: Reputation: 8
What do they do with Slax? You might be able to do something similar as they do there?
 
Old 03-22-2012, 01:12 PM   #7
johnbristol
LQ Newbie
 
Registered: Feb 2008
Posts: 12

Original Poster
Rep: Reputation: 2
It takes a while to find sufficient time to check but I now reckon this works. I can boot my USB stick whether it's /dev/sdb or /dev/sdc and the distinction is made at boot time.

13.37 Slackware /boot/initrd-tree/init
Code:
bash-4.1# cat init.diff
98a99,101
>     luksdev=UUID=*)
>       LUKSDEV=$(echo $ARG | cut -f2- -d=)
>     ;;
203a207,209
>       if echo $LUKSDEV | grep -q "UUID=" ; then
>         LUKSDEV=$(blkid | grep ${LUKSDEV:5} | awk -F':' '{print $1 }')
>       fi
bash-4.1# 

lvmdev=`blkid | grep sd$13 | awk -F'"' '{print $2 }'`
mkinitrd -c -k 2.6.37.6-smp -m ext4 twofish -f ext4 -r /dev/fdv/root -C UUID="$lvmdev" -l uk -L -K LABEL=xfer:/originalpassword.luks -w 5
My lilo.conf has boot=/dev/sdb which is the correct reference to the MBR at the time lilo is run, it has no impact at boot time. My /etc/fstab has no "/dev/sdx"-specific entries.

I note that alienBOB's existing slackware-13.37/README_CRYPT.TXT already allows the main drive to have just one LVM partition on it and nothing else, and to put /boot and (on a vfat partition) the --key-file onto a USB flash drive which can be inserted just to boot and removed before logging in. That's how I'd been running my laptop. This change to /boot/initrd-tree/init now lets me carry a bootable USB flash drive with the LVM partition on it as well, and use it on a range of host PCs.

Last edited by johnbristol; 03-22-2012 at 01:15 PM.
 
Old 03-23-2012, 08:18 AM   #8
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,393

Rep: Reputation: Disabled
Quote:
Originally Posted by johnbristol View Post
It takes a while to find sufficient time to check but I now reckon this works. I can boot my USB stick whether it's /dev/sdb or /dev/sdc and the distinction is made at boot time.

13.37 Slackware /boot/initrd-tree/init
Code:
bash-4.1# cat init.diff
98a99,101
>     luksdev=UUID=*)
>       LUKSDEV=$(echo $ARG | cut -f2- -d=)
>     ;;
203a207,209
>       if echo $LUKSDEV | grep -q "UUID=" ; then
>         LUKSDEV=$(blkid | grep ${LUKSDEV:5} | awk -F':' '{print $1 }')
>       fi
bash-4.1# 

lvmdev=`blkid | grep sd$13 | awk -F'"' '{print $2 }'`
mkinitrd -c -k 2.6.37.6-smp -m ext4 twofish -f ext4 -r /dev/fdv/root -C UUID="$lvmdev" -l uk -L -K LABEL=xfer:/originalpassword.luks -w 5
My lilo.conf has boot=/dev/sdb which is the correct reference to the MBR at the time lilo is run, it has no impact at boot time. My /etc/fstab has no "/dev/sdx"-specific entries.

I note that alienBOB's existing slackware-13.37/README_CRYPT.TXT already allows the main drive to have just one LVM partition on it and nothing else, and to put /boot and (on a vfat partition) the --key-file onto a USB flash drive which can be inserted just to boot and removed before logging in. That's how I'd been running my laptop. This change to /boot/initrd-tree/init now lets me carry a bootable USB flash drive with the LVM partition on it as well, and use it on a range of host PCs.
Perhaps this diff is a bit cleaner, but I agree that this is a good enhancement for the init script:
Code:
98a99,101
>     luksdev=UUID=*)
>       LUKSDEV=$(echo $ARG | cut -f2- -d=)
>     ;;
203a207,209
>       if echo $LUKSDEV | grep -q "UUID=" ; then
>         LUKSDEV=$(findfs $LUKSDEV)
>       fi
Eric
 
Old 03-23-2012, 11:26 AM   #9
GazL
Senior Member
 
Registered: May 2008
Posts: 3,503

Rep: Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026
Adding UUID support to LUKSDEV is definitely a nice idea, but it's not quite as simple as the above.

Since the additon of support for the unlocking of multiple luks devices in the initrd LUKSDEV is now a colon delimited list of devices to be unlocked (though most people don't use this feature).. We need to allow for:
luksdev=UUID=wibble-wibble-wibble:UUID=wobble-wobble-wobble.
or
luksdev=/dev/sda3:UUID=wibble-wibble-wibble
...and so on.

Also in theory some of these may not be available for findfs to find in the first pass such as LVM LVs that won't become visible until after the vgscan
(that's what the deferred bit is all about), so we need a little extra logic..

I've not tested this, and it's only the work of a few minutes so treat with caution but I think it'll be about right.:
Code:
gazl@slackbox:/tmp/mkinitrd$ diff -u init.orig init
--- init.orig   2011-03-21 23:04:24.000000000 +0000
+++ init        2012-03-23 15:07:33.850345426 +0000
@@ -93,7 +93,7 @@
     init=*)
       INIT=$(echo $ARG | cut -f2 -d=)
     ;;
-    luksdev=/dev/*)
+    luksdev=*)
       LUKSDEV=$(echo $ARG | cut -f2- -d=)
     ;;
     lukskey=*)
@@ -201,6 +201,11 @@
     LUKSLIST_DEFERRED=""
     LUKSLIST=$(echo $LUKSDEV | tr -s ':' ' ')
     for LUKSDEV in $LUKSLIST ; do
+      if echo $LUKSDEV | grep -q "UUID=" ; then
+        if LUKSTMP=$(findfs $LUKSDEV) ; then
+           LUKSDEV="$LUKSTMP"
+        fi
+      fi
       if /sbin/cryptsetup isLuks ${LUKSDEV} 1>/dev/null 2>/dev/null ; then
         if echo $ROOTDEV | grep -q "LABEL=" || echo $ROOTDEV | grep -q "UUID=" ; then
           CRYPTDEV="luks$(basename $LUKSDEV)"
@@ -230,6 +235,11 @@
 
   if [ -x /sbin/cryptsetup -a -n "${LUKSLIST_DEFERRED}" ]; then
     for LUKSDEV in ${LUKSLIST_DEFERRED} ; do
+      if echo $LUKSDEV | grep -q "UUID=" ; then
+        if LUKSTMP=$(findfs $LUKSDEV) ; then
+           LUKSDEV="$LUKSTMP"
+        fi
+      fi
       if /sbin/cryptsetup isLuks ${LUKSDEV} 1>/dev/null 2>/dev/null ; then
         if echo $ROOTDEV | grep -q "LABEL=" || echo $ROOTDEV | grep -q "UUID=" ; then
           CRYPTDEV="luks$(basename $LUKSDEV)"

Last edited by GazL; 03-23-2012 at 12:09 PM. Reason: fixed error in patch.
 
Old 03-23-2012, 07:01 PM   #10
johnbristol
LQ Newbie
 
Registered: Feb 2008
Posts: 12

Original Poster
Rep: Reputation: 2
I'm surprised, I thought the line
Code:
for LUKSDEV in $LUKSLIST ; do
broke the colon-delimited list into single entries each of which might be /dev/sdxn or UUID=foo, and that each was treated individually thereafter.
 
Old 03-24-2012, 04:47 AM   #11
GazL
Senior Member
 
Registered: May 2008
Posts: 3,503

Rep: Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026
You're right John, it does, but I was referring to that first hunk in the patch outside of the for-loop which wouldn't have behaved correctly to a luksdev parameter such as
luksdev=/dev/sda1:UUID=123-456-789 because it wouldn't have matched the "luksdev=UUID=*" pattern in the 'case' statement. Although that is probably somewhat of a corner case, it's wise to try and cover all the bases.

Last edited by GazL; 03-24-2012 at 04:55 AM.
 
Old 03-24-2012, 05:23 PM   #12
johnbristol
LQ Newbie
 
Registered: Feb 2008
Posts: 12

Original Poster
Rep: Reputation: 2
Either case matching selects the whole single string for processing, whether the /dev or the /UUID comes first in the list.



eta: I'm sorry,that sounded like point-scoring and it's not meant to be, that's how I discuss code at reviews whether it's mine or someone else's. I'm grateful for the analysis.

Last edited by johnbristol; 03-24-2012 at 05:25 PM.
 
1 members found this post helpful.
Old 03-24-2012, 06:05 PM   #13
GazL
Senior Member
 
Registered: May 2008
Posts: 3,503

Rep: Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026
Quote:
Originally Posted by johnbristol View Post
Either case matching selects the whole single string for processing, whether the /dev or the /UUID comes first in the list.



eta: I'm sorry,that sounded like point-scoring and it's not meant to be, that's how I discuss code at reviews whether it's mine or someone else's. I'm grateful for the analysis.
Ahh yes, fair point I was forgetting that the existing luksdev=/dev/*) would have matched that example. I still believe that replacing both those case matches with a single entry is the correct thing to do considering they both do exactly the same thing on a match, but clearly my reasoning was off.


And don't worry. I didn't take it as point-scoring. If I've missed something I'd rather people tell me. Thanks for pointing it out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] enable UUID support in kernel [WITHOUT INITRD] entz Linux - Kernel 11 10-19-2011 09:37 PM
how to boot from UUID using initrd kapsule Linux - Software 1 05-02-2011 04:54 AM
Change UUID - Edit UUID using the dd command GMHilltop Linux - Newbie 10 10-28-2010 08:39 PM
Volume has problems including no uuid in /dev/disk/by-uuid abejarano Linux - Hardware 3 12-31-2008 09:41 PM
How to add non-US keyboard layout to initrd (cryptsetup)? malo_umoran Slackware 6 04-05-2008 09:44 AM


All times are GMT -5. The time now is 12:32 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration