summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init68
1 files changed, 43 insertions, 25 deletions
diff --git a/init b/init
index 80bee3c..65bf6e8 100644
--- a/init
+++ b/init
@@ -9,6 +9,7 @@ set -- $(cat /proc/cmdline)
# We don't want to leave mount points around
umount /proc
+rootwait=true # defaults to off in the kernel, I think it's more useful on
for arg; do
case "$arg" in
root=LABEL=*)
@@ -50,6 +51,12 @@ for arg; do
fi
rootfstype="${arg#rootdelay=}"
;;
+ rootwait)
+ rootwait=true
+ ;;
+ norootwait)
+ rootwait=false
+ ;;
ro)
ro=ro
;;
@@ -75,33 +82,44 @@ EOF
fi
mount -n -t devtmpfs devtmpfs /dev
-case "$root_type" in
-disk)
- mount -n -t "${rootfstype}" -o "${ro-rw}""$rootflags" "$root" /mnt
- ;;
-label)
- disk="$(findfs LABEL="$root")"
- if [ x"$disk" = x ]; then
- echo disk with label $root not found
- blkid
- exit 1
- fi
- mount -n -t "${rootfstype}" -o "${ro-rw}""$rootflags" "$disk" /mnt
- ;;
-uuid)
- disk="$(findfs UUID="$root")"
- if [ x"$disk" = x ]; then
- echo disk with UUID $root not found
- blkid
+while true; do
+ case "$root_type" in
+ disk)
+ if mount -n -t "${rootfstype}" -o "${ro-rw}""$rootflags" "$root" /mnt; then
+ break
+ else
+ echo disk $root not found
+ blkid
+ fi
+ ;;
+ label)
+ disk="$(findfs LABEL="$root")"
+ if [ x"$disk" = x ]; then
+ echo disk with label $root not found
+ blkid
+ else
+ mount -n -t "${rootfstype}" -o "${ro-rw}""$rootflags" "$disk" /mnt && break
+ fi
+ ;;
+ uuid)
+ disk="$(findfs UUID="$root")"
+ if [ x"$disk" = x ]; then
+ echo disk with UUID $root not found
+ blkid
+ else
+ mount -n -t "${rootfstype}" -o "${ro-rw}""$rootflags" "$disk" /mnt && break
+ fi
+ ;;
+ '')
+ echo "Error, no root specified"
exit 1
+ ;;
+ esac
+ if "$rootwait"; then
+ echo Trying again in 0.5 seconds
+ sleep 0.5
fi
- mount -n -t "${rootfstype}" -o "${ro-rw}""$rootflags" "$disk" /mnt
- ;;
-'')
- echo "Error, no root specified"
- exit 1
- ;;
-esac
+done
umount -n /dev
exec switch_root -c /dev/console /mnt "${init-/sbin/init}"