From 2c7c8f295a0871f57bb9324d1bd9cd385a45d540 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 21 Mar 2012 10:21:26 -0400 Subject: init_functions: fix tag resolution w/o udev rules The combination of the udev+mdadm hooks plus a tag based root= would cause resolve_device to fail because it immediately looked for a udev symlink which would never be created. The proper fix is to get rid of the mdadm hook and to always use mdadm_udev (which should be merged into mdadm), but this might come back and bite us again. The new solution doesn't assume that udev rules exist and tries blkid first. If the device doesn't (yet) exist fall back on a udev symlink if udevd is running. Signed-off-by: Dave Reisner --- init_functions | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/init_functions b/init_functions index 58d5306..0233aa2 100644 --- a/init_functions +++ b/init_functions @@ -161,25 +161,24 @@ fsck_root() { resolve_device() { local major minor dev tagval 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. + # attempt to resolve devices immediately. if this fails + # and udev is running, fall back on lazy resolution using + # /dev/disk/by-* symlinks. this is flexible enough to support + # usage of tags without udev and "slow" devices like root on + # USB, which might not immediately show up. case $device in UUID=*) tagval=${device#*=} - if [ "$udevd_running" -eq 1 ]; then + dev=$(blkid -U "$tagval") + if [ -z "$dev" -a "$udevd_running" -eq 1 ]; then dev=/dev/disk/by-uuid/$tagval - else - dev=$(blkid -U "$tagval") fi ;; LABEL=*) tagval=${device#*=} - if [ "$udevd_running" -eq 1 ]; then + dev=$(blkid -L "$tagval") + if [ -z "$dev" -a "$udevd_running" -eq 1 ]; then dev=/dev/disk/by-label/$tagval - else - dev=$(blkid -L "$tagval") fi ;; esac -- cgit v1.2.3-24-g4f1b