From 2783f96ce7727fd1ed7d256825a3c133016286d9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 8 Aug 2008 23:15:36 +0000 Subject: [PATCH] * Remove the sleep-5-seconds hack in the initrd, instead loop until the device to mount appears. This wasn't previously possible because of root devices specified by label (mounted via "mount LABEL=foo ..."), but now we use /dev/disk/by-label so we can easily test whether the device already exists. svn path=/nixos/trunk/; revision=12562 --- boot/boot-stage-1-init.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/boot/boot-stage-1-init.sh b/boot/boot-stage-1-init.sh index 83a06c7d7dd..9bef32dcaf4 100644 --- a/boot/boot-stage-1-init.sh +++ b/boot/boot-stage-1-init.sh @@ -155,10 +155,6 @@ mountFS() { # Try to find and mount the root device. mkdir /mnt-root -echo "mounting the root device.... (fix: sleeping 5 seconds to wait for upcoming usb drivers)" -sleep 5 - -# Hard-coded root device(s). mountPoints=(@mountPoints@) devices=(@devices@) fsTypes=(@fsTypes@) @@ -182,6 +178,22 @@ for ((n = 0; n < ${#mountPoints[*]}; n++)); do ;; esac + # USB storage devices tend to appear with some delay. It would be + # great if we had a way to synchronously wait for them, but + # alas... So just wait for a few seconds for the device to + # appear. If it doesn't appear, try to mount it anyway (and + # probably fail). This is a fallback for non-device "devices" + # that we don't properly recognise (like NFS mounts). + if ! test -e $device; then + echo -n "waiting for device $device to appear..." + for ((try = 0; try < 10; try++)); do + sleep 1 + if test -e $device; then break; fi + echo -n "." + done + echo + fi + echo "mounting $device on $mountPoint..." mountFS "$device" "$mountPoint" "$options" "$fsType"