commit:     67893b749b83fd716e55fa7c865f4c924454ee24
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon May 16 06:40:43 2016 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon May 16 06:49:04 2016 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=67893b74

defaults/linuxrc: bug #232733: implement rootwait.

Based on patch from John Klug <ski.brimson <AT> gmail.com>.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 defaults/initrd.defaults |  1 +
 defaults/linuxrc         | 15 +++++++++++++++
 doc/genkernel.8.txt      |  5 +++++
 3 files changed, 21 insertions(+)

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index a5eb3ba..b63ebd0 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -60,6 +60,7 @@ REAL_ROOT=''
 CONSOLE='/dev/console'
 NEW_ROOT='/newroot'
 
no_umounts='/newroot|/mnt/aufs-dev|/mnt/aufs-rw-branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino'
+ROOTDELAY=1
 CDROOT='0'
 CDROOT_DEV=''
 CDROOT_TYPE='auto'

diff --git a/defaults/linuxrc b/defaults/linuxrc
index ac8f215..72e1543 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -133,6 +133,12 @@ do
                scandelay)
                        SDELAY=3
                ;;
+               rootdelay=*|rootwait=*)
+                       ROOTDELAY=${x#*=}
+               ;;
+               rootdelay|rootwait)
+                       ROOTDELAY=5
+               ;;
                # Module no-loads
                doload=*)
                        MDOLIST=${x#*=}
@@ -485,10 +491,14 @@ fi
 
 # Determine root device
 good_msg 'Determining root device ...'
+ROOTDELAY_100MSEC=1
+[ -n "${ROOTDELAY}" ] && ROOTDELAY_100MSEC=$(($ROOTDELAY * 10))
 while true
 do
        while [ "${got_good_root}" != '1' ]
        do
+               # Start of sleep loop waiting on root
+               while [ ${ROOTDELAY_100MSEC} -ge 0 -a "${got_good_root}" != '1' 
] ; do
                case "${REAL_ROOT}" in
                        LABEL=*|UUID=*)
 
@@ -574,6 +584,11 @@ do
                                ;;
                esac
 
+               if [ "${got_good_root}" != '1' ] ; then
+                 let ROOTDELAY_100MSEC=${ROOTDELAY_100MSEC}-1
+                 usleep 100
+               fi
+               done  # End of sleep loop waiting on root
                if [ "${REAL_ROOT}" = '' ]
                then
                        # No REAL_ROOT determined/specified. Prompt user for 
root block device.

diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index ab534cd..bab1034 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -464,6 +464,11 @@ which the ramdisk & initramfs scripts would recognize.
     Pauses for 10 seconds before running devfsd if no argument is
     specified; otherwise pauses for the number of specified seconds.
 
+*rootdelay*[=<...>]::
+*rootwait*[=<...>]::
+       Pauses for up to 3 seconds (or specified number of seconds) while
+       waiting for root device to appear during initramfs root scanning.
+
 *ip*=<...>::
     Normally used to tell the kernel that it should start a network
     interface. If present, the initrd will try to mount a  livecd

Reply via email to