From 062c5d3aece2e308aa7fc03acab1b3b6dd4270b2 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 26 Mar 2015 14:06:30 +0000 Subject: Support rootwait (enabled by default) Change-Id: Ie1cb0c136cb9bc2873d86bbc244dcacdcf85b65d --- init | 68 +++++++++++++++++++++++++++++++++++++++++++------------------------- 1 file 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}" -- cgit v1.2.1