diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2016-07-01 15:53:51 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-07-08 09:55:41 +0100 |
commit | 2a50bb9ee8838e3d026c82dc09aaccb880a264f4 (patch) | |
tree | 0328166e340cc84bab4685d8cdab3692ee07f4c2 /meta/recipes-core/initrdscripts/initramfs-framework/rootfs | |
parent | b1f2d9ed8d4dc89c9e669f43f546463ccc2a76b9 (diff) | |
download | openembedded-core-contrib-2a50bb9ee8838e3d026c82dc09aaccb880a264f4.tar.gz |
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@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/recipes-core/initrdscripts/initramfs-framework/rootfs')
-rw-r--r-- | meta/recipes-core/initrdscripts/initramfs-framework/rootfs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/rootfs b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs new file mode 100644 index 0000000000..5790d8cb8b --- /dev/null +++ b/meta/recipes-core/initrdscripts/initramfs-framework/rootfs @@ -0,0 +1,57 @@ +#!/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +rootfs_enabled() { + return 0 +} + +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 + 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" ] && ! echo "$bootparam_rootflags" | grep -w -q "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 + 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 + debug "Sleeping for $delay second(s) to wait root to settle..." + sleep $delay + C=$(( $C + 1 )) + done +} |