LinuxQuestions.org
Visit Jeremy's Blog.
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 04-13-2018, 09:13 PM   #1
Xsane
Member
 
Registered: Jan 2014
Posts: 148

Rep: Reputation: 112Reputation: 112
Make initrd luksdev UUID aware


For the same reasons UUID is required for lilo, it is needed in initrd.

I was just caught out by this. A change in a system caused its scsi interfaces to initialize
in a different order. /dev/sdb became /dev/sdf and the system was kaput.

Although undocumented initrd rootdev is currently UUID aware.

mkinitrd can already handle -C UUID=<blah>, but initrd init needed some help.

Patch for: slackware64-current/source/a/mkinitrd/init
Code:
diff --git a/init b/init
index 08aabe2..93bb320 100755
--- a/init
+++ b/init
@@ -221,6 +221,10 @@ if [ "$RESCUE" = "" ]; then
     LUKSLIST_DEFERRED=""
     LUKSLIST=$(echo $LUKSDEV | tr -s ':' ' ')
     for LUKSDEV in $LUKSLIST ; do
+      if echo $LUKSDEV | grep -q "LABEL=" || \
+         echo $LUKSDEV | grep -q "UUID=" ; then
+        LUKSDEV=$(findfs $LUKSDEV)
+      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)"
Update man pages:
Code:
diff --git a/mkinitrd.8 b/mkinitrd.8
index 64dad3f..4518bf2 100644
--- a/mkinitrd.8
+++ b/mkinitrd.8
@@ -71,8 +71,8 @@ mkinitrd \- create or rebuilt an initrd (initial ramdisk) using initramfs (simpl
 is used to build an initial ramdisk.  An initial ramdisk is a very small
 set of files that are loaded into RAM and "mounted" (as initramfs doesn't
 actually use a filesystem) as the kernel boots (before the main root
-filesystem is mounted).  The usual reason to use an initrd is because
-you need to load kernel modules before mounting the root partition.
+filesystem is mounted).  An initrd may be required to unlock an encrypted
+device and/or load kernel modules in order to access the root partition.
 Usually these modules are required to support the filesystem used by the
 root partition (ext3, reiserfs, xfs), or perhaps the controller that the
 hard drive is attached to (SCSI, RAID, etc).  Essentially, there are so many
@@ -124,10 +124,12 @@ Additional options may be added to use when loading the kernel modules
 .B \-o output image
 The file to write the initrd to.  (default: /boot/initrd.gz)
 .TP
-.B \-r root partition
+.BI \-r \ root_device
 Specify the device to be used as the root partition.  If this isn't given, the
 kernel default will be used (which is usually fine).  This option must be used
 together with the \-f option in order to be beneficial.
+.I root_device
+can be a device node path, UUID, or LABEL. See examples for \fB\-C\fR below.
 .TP
 .B \-s source tree
 The directory to use as the source for the initrd.  (default: /boot/initrd-tree/)
@@ -139,16 +141,22 @@ Include udev in the initrd.
 The -w option specifies how long to wait in seconds before assuming that all the
 drives are spun up and ready to go.
 .TP
-.B \-C device list
+.BI \-C \ device_list
 A colon (:) delimited list of luks encrypted block devices to be unlocked by
-the initrd using cryptsetup.  All devices that must be unlocked in order to
-access the root filesystem must be specified. e.g.
+the initrd using cryptsetup.
+.I device_list
+may include any of: device node path, UUID, or LABEL.  All devices that must be
+unlocked in order to access the root filesystem must be specified. For example:
 
   -C /dev/sda2:/dev/sda3
+.br
+  -C UUID=ec6dea40-c8d8-4590-850a-a757be60e45a
+.br
+  -C LABEL=darkstar
 
 Each unlocked device will be assigned an automatically generated luks device
 name of the form luks<device> where '<device>' will be the basename of the
-encrypted device.  e.g.
+encrypted device node path. For example:
 
   /dev/mapper/lukssda2
 
diff --git a/mkinitrd.conf.5 b/mkinitrd.conf.5
index b46db61..b28a6e0 100644
--- a/mkinitrd.conf.5
+++ b/mkinitrd.conf.5
@@ -94,10 +94,15 @@ Example: MODULE_LIST="module1:module2 option=1:module3"
 .TP 5
 .I LUKSDEV
 Contains a colon (:) delimited list of luks encrypted block devices to be
-unlocked by the initrd using cryptsetup.  All devices that must be unlocked
-in order to access the root filesystem must be specified.
-.br
+unlocked by the initrd using cryptsetup.  The list may include any of: device
+node path, UUID, or LABEL.  All devices that must be unlocked in order to
+access the root filesystem must be specified.
+.sp
 Example: LUKSDEV="/dev/sda2:/dev/sda3"
+.br
+Example: LUKSDEV="UUID=ec6dea40-c8d8-4590-850a-a757be60e45a"
+.br
+Example: LUKSDEV="LABEL=darkstar"
 
 Each unlocked device will be assigned an automatically generated luks device
 name of the form luks<device> where '<device>' will be the basename of the
@@ -147,6 +152,7 @@ Example: LUKSTRIM="/dev/sda2:/dev/sda4"
 .TP 5
 .I ROOTDEV
 The device on which your root filesystem is located.
+May be a device node path, UUID, or LABEL. See LUKSDEV examples.
 .br
 Example: ROOTDEV="/dev/sda2"
TODO
initrd_command_generator.sh should use UUID's when udev is included in the initrd.
 
Old 04-13-2018, 11:17 PM   #2
glorsplitz
Member
 
Registered: Dec 2002
Distribution: slackware!
Posts: 655

Rep: Reputation: 130Reputation: 130
A little off topic but there's been other posts of people having their /dev/sdX interfaces initialize in a different order.

Why isn't UUID [A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems] always used when bringing up /dev/sdX interfaces?
 
Old 04-13-2018, 11:41 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,235

Rep: Reputation: 2636Reputation: 2636Reputation: 2636Reputation: 2636Reputation: 2636Reputation: 2636Reputation: 2636Reputation: 2636Reputation: 2636Reputation: 2636Reputation: 2636
Because UUIDs aren't - clone backups being the most obvious example.
gpt partition UUID largely solve this, but collisions are still possible.
 
Old 04-14-2018, 01:57 AM   #4
Darth Vader
Senior Member
 
Registered: May 2008
Location: Romania
Distribution: DARKSTAR Linux 2008.1
Posts: 2,727

Rep: Reputation: 1231Reputation: 1231Reputation: 1231Reputation: 1231Reputation: 1231Reputation: 1231Reputation: 1231Reputation: 1231Reputation: 1231
Quote:
Originally Posted by glorsplitz View Post
A little off topic but there's been other posts of people having their /dev/sdX interfaces initialize in a different order.

Why isn't UUID [A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems] always used when bringing up /dev/sdX interfaces?
Because for the typical members of species Homo Sapiens Sapiens is more easy to remember /dev/sdc7 instead of b91dcdb4-4c11-47e2-b134-3b2aec1e3418 even those abstractions refer to the same partition.

The scientists still try to understand the phenomena, no consensus was reached yet...

Last edited by Darth Vader; 04-14-2018 at 03:17 AM.
 
1 members found this post helpful.
Old 04-14-2018, 12:19 PM   #5
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,092

Rep: Reputation: 1469Reputation: 1469Reputation: 1469Reputation: 1469Reputation: 1469Reputation: 1469Reputation: 1469Reputation: 1469Reputation: 1469Reputation: 1469
Another case where LVM would help; the physical volumes are identified by UUID under the covers. The logical volumes don't care.
 
  


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] initrd can't boot from BTRFS filesystem passed by UUID bam80 Slackware 5 07-16-2017 07:55 AM
UUID= syntax not recognized by cryptsetup in initrd LUKSDEV johnbristol Slackware - Installation 12 03-24-2012 06:05 PM
[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
How to make KDE aware of JAVA Jordan&&&& Linux - Newbie 5 09-20-2006 03:02 PM

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

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