aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2019-07-16 18:06:43 +0200
committerThomas Deutschmann <whissi@gentoo.org>2019-07-16 18:28:08 +0200
commitc4616417e5c827a1ddf4daa89de82922fecda904 (patch)
tree50d9cd16f832002efac8188f73fac8679f127c96
parentgen_initramfs.sh: create_initramfs(): When deduping CPIO, use --reproducible ... (diff)
downloadgenkernel-c4616417e5c827a1ddf4daa89de82922fecda904.tar.gz
genkernel-c4616417e5c827a1ddf4daa89de82922fecda904.tar.bz2
genkernel-c4616417e5c827a1ddf4daa89de82922fecda904.zip
linuxrc: Change ROOTDELAY handling
Before this change we converted $ROOTDELAY into microseconds and decremented that value on each loop iteration. Once that value was <=0 we threw a timeout. Because we substracted a fixed value we didn't take into account that a command from loop could already have taken some time. During testing, in worst case, running with ROOTDELAY=10 and invalid root=UUID= parameter, it was seen that it took up to ~35s instead of 10s before linuxrc prompted for new root value. With this change, we now set a timeout based on current time in seconds + ROOTDELAY. Loop will end if current time is >= timeout. In addition, ROOTDELAY default value was changed from 1 to 5. Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r--defaults/initrd.defaults2
-rw-r--r--defaults/linuxrc18
2 files changed, 12 insertions, 8 deletions
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index 7d941d5..fbbd214 100644
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -60,7 +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
+ROOTDELAY=5
CDROOT='0'
CDROOT_DEV=''
CDROOT_TYPE='auto'
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 4706055..6b69a13 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -593,8 +593,9 @@ then
fi
# Determine root device
-ROOTDELAY_100MSEC=1
-[ -n "${ROOTDELAY}" ] && ROOTDELAY_100MSEC=$((${ROOTDELAY} * 10))
+let ROOTDELAY_TIMEOUT=$(date +%s)+1
+ROOTDELAY_TIME_WAITED=0
+[ -n "${ROOTDELAY}" -a ${ROOTDELAY} -gt 0 ] && let ROOTDELAY_TIMEOUT=${ROOTDELAY_TIMEOUT}+${ROOTDELAY}-1
while true
do
good_msg_n 'Determining root device ...'
@@ -602,7 +603,7 @@ do
while [ "${got_good_root}" != '1' ]
do
# Start of sleep loop waiting on root
- while [ ${ROOTDELAY_100MSEC} -ge 0 -a "${got_good_root}" != '1' ]
+ while [ "${got_good_root}" != '1' -a $(date +%s) -le ${ROOTDELAY_TIMEOUT} ]
do
case "${REAL_ROOT}" in
LABEL=*|UUID=*|PARTUUID=*)
@@ -676,6 +677,7 @@ do
if [ -b "${REAL_ROOT}" ]
then
got_good_root=1
+ echo
good_msg "Detected real_root=${REAL_ROOT}"
break
fi
@@ -684,10 +686,10 @@ do
if [ "${got_good_root}" != '1' ]
then
- let ROOTDELAY_100MSEC=${ROOTDELAY_100MSEC}-1
+ let ROOTDELAY_TIME_WAITED=${ROOTDELAY_TIME_WAITED}+1
sleep 0.1s
- let ROOTDELAY_100MSEC_MODULO=${ROOTDELAY_100MSEC}%10
+ let ROOTDELAY_100MSEC_MODULO=${ROOTDELAY_TIME_WAITED}%10
if [ ${ROOTDELAY_100MSEC_MODULO} = 0 ]
then
printf "."
@@ -695,13 +697,13 @@ do
fi
done # End of sleep loop waiting on root
- if [ ${ROOTDELAY_100MSEC} -le 0 ]
+ if [ $(date +%s) -gt ${ROOTDELAY_TIMEOUT} ]
then
echo
fi
# Check for a block device or /dev/nfs or zfs encryption
- if [ -n "${REAL_ROOT}" ] && [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ] || [ "${ROOTFSTYPE}" = "zfs" ]
+ if [ -n "${REAL_ROOT}" ] && [ "${REAL_ROOT}" = "/dev/nfs" ] || [ "${ROOTFSTYPE}" = "zfs" ] || [ -b "${REAL_ROOT}" ]
then
if [ "${ROOTFSTYPE}" = "zfs" ]
then
@@ -803,6 +805,8 @@ do
then
bad_msg "Block device ${REAL_ROOT} is not a valid root device ..."
prompt_user "REAL_ROOT" "root block device"
+ ROOTDELAY_TIME_WAITED=0
+ let ROOTDELAY_TIMEOUT=$(date +%s)+1
fi
done
# End determine root device