summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Folkesson <marcus.folkesson@gmail.com>2022-05-27 09:15:52 +0200
committerMarcus Folkesson <marcus.folkesson@gmail.com>2022-05-27 09:15:52 +0200
commitb89c636859705b8927d8f10481443a3b2281df7e (patch)
treee62fbed25cf8ce3cf24ac3a8b5eb19d7da74dc61
parentb44889b7bbaf9f2b88322b6989833712a17dcc6a (diff)
downloadmeta-readonly-rootfs-overlay-b89c636859705b8927d8f10481443a3b2281df7e.tar.gz
init-readonly-rootfs-overlay-boot: wait for device to show up
Some devices such as external MMCs could be probed after the init process has started. Wait at most 5s for root and roroot to be available. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
-rw-r--r--recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
index 66f0cdc..b990344 100644
--- a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
+++ b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
@@ -77,6 +77,18 @@ log() {
77 echo "rorootfs-overlay: $1" >$CONSOLE 77 echo "rorootfs-overlay: $1" >$CONSOLE
78} 78}
79 79
80wait_for_device() {
81 counter=0
82 while [ ! -b $1 ]; do
83 sleep .100
84 counter=$((counter + 1))
85 if [ $counter -ge 50 ]; then
86 fatal "$1 is not availble"
87 exit
88 fi
89 done
90}
91
80early_setup 92early_setup
81 93
82[ -z "${CONSOLE+x}" ] && CONSOLE="/dev/console" 94[ -z "${CONSOLE+x}" ] && CONSOLE="/dev/console"
@@ -89,6 +101,7 @@ mount_and_boot() {
89 # Build mount options for read only root file system. 101 # Build mount options for read only root file system.
90 # If no read-only device was specified via kernel command line, use 102 # If no read-only device was specified via kernel command line, use
91 # current root file system via bind mount. 103 # current root file system via bind mount.
104 wait_for_device ${ROOT_RODEVICE}
92 ROOT_ROMOUNTPARAMS_BIND="-o ${ROOT_ROMOUNTOPTIONS} /" 105 ROOT_ROMOUNTPARAMS_BIND="-o ${ROOT_ROMOUNTOPTIONS} /"
93 if [ -n "${ROOT_RODEVICE}" ]; then 106 if [ -n "${ROOT_RODEVICE}" ]; then
94 ROOT_ROMOUNTPARAMS="-o ${ROOT_ROMOUNTOPTIONS_DEVICE} $ROOT_RODEVICE" 107 ROOT_ROMOUNTPARAMS="-o ${ROOT_ROMOUNTOPTIONS_DEVICE} $ROOT_RODEVICE"
@@ -123,6 +136,7 @@ mount_and_boot() {
123 # Build mount options for read write root file system. 136 # Build mount options for read write root file system.
124 # If a read-write device was specified via kernel command line, use 137 # If a read-write device was specified via kernel command line, use
125 # it, otherwise default to tmpfs. 138 # it, otherwise default to tmpfs.
139 wait_for_device ${ROOT_RWDEVICE}
126 if [ -n "${ROOT_RWDEVICE}" ]; then 140 if [ -n "${ROOT_RWDEVICE}" ]; then
127 141
128 ROOT_RWMOUNTPARAMS="-o $ROOT_RWMOUNTOPTIONS_DEVICE $ROOT_RWDEVICE" 142 ROOT_RWMOUNTPARAMS="-o $ROOT_RWMOUNTOPTIONS_DEVICE $ROOT_RWDEVICE"