[oe-commits] [openembedded-core] 37/40: initramfs-framework: add retry loop for slow boot devices (like USB)
git at git.openembedded.org
git at git.openembedded.org
Thu Jul 7 12:39:28 UTC 2016
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit 59ebd5aa9aceba046ddda7dd5a5edd7922653d27
Author: Patrick Ohly <patrick.ohly at intel.com>
AuthorDate: Fri Jul 1 15:53:51 2016 +0200
initramfs-framework: add retry loop for slow boot devices (like USB)
On some hardware platforms (Gigabyte, qemu), detection of USB devices
by the kernel is slow enough such that it happens only after the first
attempt to mount the rootfs. We need to keep trying for a while
(default: 5s seconds, controlled by roottimeout=<seconds>) and sleep
between each attempt (default: one second, rootdelay=<seconds>).
This change intentionally splits finding the rootfs (in the new
"rootfs") and switching to it ("finish"). That is needed to keep udev
running while waiting for the rootfs, because it shuts down before
"finish" starts. It is also the direction that was discussed on the OE
mailing list for future changes to initramfs-framework (like
supporting a "live CD" module, which would replace or further augment
mounting of the rootfs).
Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>
---
.../initrdscripts/initramfs-framework/finish | 33 --------------
.../initramfs-framework/{finish => rootfs} | 51 ++++++++++------------
.../initrdscripts/initramfs-framework_1.0.bb | 4 +-
3 files changed, 27 insertions(+), 61 deletions(-)
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index d09bbb8..717383e 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -8,39 +8,6 @@ finish_enabled() {
finish_run() {
if [ -n "$ROOTFS_DIR" ]; then
- if [ -n "$bootparam_rootdelay" ]; then
- debug "Sleeping for $rootdelay second(s) to wait root to settle..."
- sleep $bootparam_rootdelay
- fi
-
- if [ -n "$bootparam_root" ]; then
- debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..."
-
- if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then
- root_uuid=`echo $bootparam_root | cut -c6-`
- bootparam_root="/dev/disk/by-uuid/$root_uuid"
- fi
-
- if [ -e "$bootparam_root" ]; then
- flags=""
- if [ -n "$bootparam_ro" ]; then
- if [ -n "$bootparam_rootflags" ]; then
- bootparam_rootflags="$bootparam_rootflags,"
- fi
- bootparam_rootflags="${bootparam_rootflags}ro"
- fi
- if [ -n "$bootparam_rootflags" ]; then
- flags="$flags -o$bootparam_rootflags"
- fi
- if [ -n "$bootparam_rootfstype" ]; then
- flags="$flags -t$bootparam_rootfstype"
- fi
- mount $flags $bootparam_root $ROOTFS_DIR
- else
- msg "root '$bootparam_root' doesn't exist."
- fi
- fi
-
if [ ! -d $ROOTFS_DIR/dev ]; then
fatal "ERROR: There's no '/dev' on rootfs."
fi
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs
old mode 100755
new mode 100644
similarity index 53%
copy from meta/recipes-core/initrdscripts/initramfs-framework/finish
copy to meta/recipes-core/initrdscripts/initramfs-framework/rootfs
index d09bbb8..5790d8c
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs
@@ -2,15 +2,20 @@
# Copyright (C) 2011 O.S. Systems Software LTDA.
# Licensed on MIT
-finish_enabled() {
+rootfs_enabled() {
return 0
}
-finish_run() {
- if [ -n "$ROOTFS_DIR" ]; then
- if [ -n "$bootparam_rootdelay" ]; then
- debug "Sleeping for $rootdelay second(s) to wait root to settle..."
- sleep $bootparam_rootdelay
+rootfs_run() {
+ if [ -z "$ROOTFS_DIR" ]; then
+ return
+ fi
+ C=0
+ delay=${bootparam_rootdelay:-1}
+ timeout=${bootparam_roottimeout:-5}
+ while [ ! -d $ROOTFS_DIR/dev ]; do
+ if [ $(( $C * $delay )) -gt $timeout ]; then
+ fatal "root '$bootparam_root' doesn't exist or does not contain a /dev."
fi
if [ -n "$bootparam_root" ]; then
@@ -23,7 +28,7 @@ finish_run() {
if [ -e "$bootparam_root" ]; then
flags=""
- if [ -n "$bootparam_ro" ]; then
+ if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then
if [ -n "$bootparam_rootflags" ]; then
bootparam_rootflags="$bootparam_rootflags,"
fi
@@ -36,25 +41,17 @@ finish_run() {
flags="$flags -t$bootparam_rootfstype"
fi
mount $flags $bootparam_root $ROOTFS_DIR
- else
- msg "root '$bootparam_root' doesn't exist."
- fi
- fi
-
- if [ ! -d $ROOTFS_DIR/dev ]; then
- fatal "ERROR: There's no '/dev' on rootfs."
+ if [ -d $ROOTFS_DIR/dev ]; then
+ break
+ else
+ # It is unlikely to change, but keep trying anyway.
+ # Perhaps we pick a different device next time.
+ umount $ROOTFS_DIR
+ fi
+ fi
fi
-
- info "Switching root to '$ROOTFS_DIR'..."
-
- debug "Moving /dev, /proc and /sys onto rootfs..."
- mount --move /dev $ROOTFS_DIR/dev
- mount --move /proc $ROOTFS_DIR/proc
- mount --move /sys $ROOTFS_DIR/sys
-
- cd $ROOTFS_DIR
- exec switch_root -c /dev/console $ROOTFS_DIR ${bootparam_init:-/sbin/init}
- else
- debug "No rootfs has been set"
- fi
+ debug "Sleeping for $delay second(s) to wait root to settle..."
+ sleep $delay
+ C=$(( $C + 1 ))
+ done
}
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
index e5cf9cb..89e153d 100644
--- a/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
+++ b/meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb
@@ -8,6 +8,7 @@ PR = "r2"
inherit allarch
SRC_URI = "file://init \
+ file://rootfs \
file://finish \
file://mdev \
file://udev \
@@ -21,6 +22,7 @@ do_install() {
# base
install -m 0755 ${WORKDIR}/init ${D}/init
+ install -m 0755 ${WORKDIR}/rootfs ${D}/init.d/90-rootfs
install -m 0755 ${WORKDIR}/finish ${D}/init.d/99-finish
# mdev
@@ -47,7 +49,7 @@ PACKAGES = "${PN}-base \
initramfs-module-e2fs \
initramfs-module-debug"
-FILES_${PN}-base = "/init /init.d/99-finish /dev"
+FILES_${PN}-base = "/init /init.d/90-rootfs /init.d/99-finish /dev"
SUMMARY_initramfs-module-mdev = "initramfs support for mdev"
RDEPENDS_initramfs-module-mdev = "${PN}-base busybox-mdev"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list