diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-03-03 03:09:49 +0100 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2012-03-04 01:24:11 +0100 |
commit | 57e275a08d46f976ab2a2edf9b7b507bbca1d1ca (patch) | |
tree | f6f0af92dcc0eb2fed7241fa3606f1c01c6ef53b /init_functions | |
parent | f62b6e1986b815a1e05dff94e7298deab5e433b5 (diff) | |
download | mkinitcpio-57e275a08d46f976ab2a2edf9b7b507bbca1d1ca.tar.gz mkinitcpio-57e275a08d46f976ab2a2edf9b7b507bbca1d1ca.tar.xz |
init_functions: lazily resolve UUID/LABEL tags
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@archlinux.org>
Diffstat (limited to 'init_functions')
-rw-r--r-- | init_functions | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/init_functions b/init_functions index e9a0cb9..bf6f11a 100644 --- a/init_functions +++ b/init_functions @@ -154,16 +154,33 @@ fsck_root() { } resolve_device() { - local major minor dev device=$1 + 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. case $device in - # resolve tag name to block device - UUID=*|LABEL=*) - dev=$(blkid -lt "$device" -o device) - [ -n "$device" ] && device=$dev + UUID=*) + tagval=${device#*=} + if [ "$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=/dev/disk/by-label/$tagval + else + dev=$(blkid -L "$tagval") + fi ;; esac + [ -n "$dev" ] && device=$dev + case $device in /dev/*) if poll_device "$device" "$rootdelay"; then |