Skip to content

Commit

Permalink
Merge pull request #3527 from balena-os/mtoman/abroot-wait
Browse files Browse the repository at this point in the history
initrdscripts: Wait for boot partition in the abroot script
  • Loading branch information
flowzone-app[bot] authored Oct 10, 2024
2 parents 15a4564 + 2ede3ce commit 8a0a76d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions meta-balena-common/recipes-core/initrdscripts/files/abroot
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,27 @@ abroot_enabled() {
abroot_run() {
BOOT_PART=$(find_boot_partition)

if [ "x${BOOT_PART}" = "x" ]; then
fail "Failed to identify boot partition"
fi
# Give the boot partition 5s to appear.
# This is necessary when the rootfs is on a device that takes
# a while to initialize, such as a USB disk.
# Similar waiting already happens in the rootfs script, because
# on most device types it is the first one that needs to access
# the root device. But in the case of balena bootloader, the abroot
# script is called before rootfs, so it needs to do the waiting.
C=0
delay=${bootparam_rootdelay:-1}
timeout=${bootparam_roottimeout:-5}
while [ -z "${BOOT_PART}" ]; do
C=$(( C + 1 ))

if [ $(( C * delay )) -gt "$timeout" ]; then
fail "Failed to identify boot partition"
fi

sleep "${delay}"

BOOT_PART=$(find_boot_partition)
done

BOOT_DEV="/dev/$(lsblk -nlo pkname ${BOOT_PART})"

Expand Down

0 comments on commit 8a0a76d

Please sign in to comment.