From abca4acbe01f4fa873ae99a3dba35b0cd9ca6730 Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Thu, 18 Apr 2024 21:51:58 +0100 Subject: [PATCH] postmarketos-initramfs: better wait_[br]oot_partition (MR 5048) Rework the messages and avoid re-spawning the splash on every check. Additionally, add a call to check_keys, this lets users drop to a debug shell or export logs to triage this failure (particularly useful for hard-to-reproduce issues). Finally, add a (liberal) 30 second timeout and dump logs at the end. If we're just waiting for a device to show up and it doesn't after 30 seconds then it's probably never going to... Signed-off-by: Caleb Connolly --- main/postmarketos-initramfs/init.sh | 3 ++ main/postmarketos-initramfs/init_functions.sh | 38 ++++++++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/main/postmarketos-initramfs/init.sh b/main/postmarketos-initramfs/init.sh index 0b355f280..8180d4b15 100644 --- a/main/postmarketos-initramfs/init.sh +++ b/main/postmarketos-initramfs/init.sh @@ -103,6 +103,9 @@ elif ! grep -q "pmos.debug-shell" /proc/cmdline; then exec >/dev/null 2>&1 fi +# Make it clear that we're at the end of the initramfs +show_splash "Starting..." + # Re-enable kmsg ratelimiting (might have been disabled for logging) echo ratelimit > /proc/sys/kernel/printk_devkmsg diff --git a/main/postmarketos-initramfs/init_functions.sh b/main/postmarketos-initramfs/init_functions.sh index b15203ca1..2d4fe2a6c 100644 --- a/main/postmarketos-initramfs/init_functions.sh +++ b/main/postmarketos-initramfs/init_functions.sh @@ -397,23 +397,41 @@ extract_initramfs_extra() { } wait_boot_partition() { - while [ -z "$(find_boot_partition)" ]; do - show_splash "ERROR: boot partition not found, retrying...\\nhttps://postmarketos.org/troubleshooting" - echo "Could not find the boot partition." - echo "If your install is on a removable disk, maybe you need to insert it?" - echo "Trying again..." + find_boot_partition + if [ -n "$PMOS_BOOT" ]; then + return + fi + + show_splash "Waiting for boot partition..." + for _ in $(seq 1 30); do + if [ -n "$(find_boot_partition)" ]; then + return + fi sleep 1 + check_keys "" done + + show_splash "ERROR: Boot partition not found!\\nhttps://postmarketos.org/troubleshooting" + fail_halt_boot } wait_root_partition() { - while [ -z "$(find_root_partition)" ]; do - show_splash "ERROR: root partition not found, retrying...\\nhttps://postmarketos.org/troubleshooting" - echo "Could not find the rootfs." - echo "If your install is on a removable disk, maybe you need to insert it?" - echo "Trying again..." + find_root_partition + if [ -n "$PMOS_ROOT" ]; then + return + fi + + show_splash "Waiting for root partition..." + for _ in $(seq 1 30); do + if [ -n "$(find_root_partition)" ]; then + return + fi sleep 1 + check_keys "" done + + show_splash "ERROR: Root partition not found!\\nhttps://postmarketos.org/troubleshooting" + fail_halt_boot } delete_old_install_partition() {