[arch-projects] [mkinitcpio][PATCH 3/6] init_functions: lazily resolve UUID/LABEL tags

Dave Reisner d at falconindy.com
Sat Mar 3 17:47:41 EST 2012


Relying on blkid to do tag resolution will fail when the root device
doesn't yet exist. This is, of course, bad for USB root devices.

Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
Also fixes a really unfortunate typo that I'm surprised hasn't caused
more issues...

 init_functions |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/init_functions b/init_functions
index e9a0cb9..5bcc159 100644
--- a/init_functions
+++ b/init_functions
@@ -156,14 +156,29 @@ fsck_root() {
 resolve_device() {
     local major minor dev device=$1
 
+    # do lazy resolution of devices by tag when udev is
+    # available. this allows us to wait on disks that
+    # might not show up immediately (e.g. USB). If udev
+    # isn't running, fall back on using blkid.
     case $device in
-        # resolve tag name to block device
-        UUID=*|LABEL=*)
-            dev=$(blkid -lt "$device" -o device)
-            [ -n "$device" ] && device=$dev
+        UUID=*)
+            if [ "$udevd_running" -eq 1 ]; then
+                dev=/dev/disk/by-uuid/${device#UUID=}
+            else
+                dev=$(blkid -lt "$device" -o device)
+            fi
+            ;;
+        LABEL=*)
+            if [ "$udevd_running" -eq 1 ]; then
+                dev=/dev/disk/by-label/${device#LABEL=}
+            else
+                dev=$(blkid -lt "$device" -o device)
+            fi
             ;;
     esac
 
+    [ -n "$dev" ] && device=$dev
+
     case $device in
         /dev/*)
             if poll_device "$device" "$rootdelay"; then
-- 
1.7.9.2



More information about the arch-projects mailing list