From cb3245f9ee6972890db958de047f116366002f79 Mon Sep 17 00:00:00 2001 From: SolidHal Date: Tue, 8 Dec 2020 21:56:13 -0800 Subject: [PATCH] Sometime when booting from USB the kernel doesn't enumerate devices fast enough, leaving us unable to find the device we are booting from. Give the kernel some time. Fixes #255 --- initramfs/resources/initramfs-init | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/initramfs/resources/initramfs-init b/initramfs/resources/initramfs-init index 60153c43e..c632a86f2 100644 --- a/initramfs/resources/initramfs-init +++ b/initramfs/resources/initramfs-init @@ -65,15 +65,38 @@ mount -n -t devtmpfs devtmpfs /dev # get the root device, so we can find the boot partiton UNPARSED=$(cmdline root) +echo Unparsed cmdline rootdev: ${UNPARSED} > /dev/tty1 ROOT_PARTUUID=$(rootpartuuid $UNPARSED) -echo ${ROOT_PARTUUID} > /dev/tty1 +echo ROOT_PARTUUID: ${ROOT_PARTUUID} > /dev/tty1 + BLKID=$(/sbin/blkid | grep $ROOT_PARTUUID ) -echo ${BLKID} > /dev/tty1 +echo BLKID: ${BLKID} > /dev/tty1 +if [ -z "$BLKID" ] +then + echo BLKID wasnt found yet, give the kernel a moment... > /dev/tty1 + sleep 1 + BLKID=$(/sbin/blkid | grep $ROOT_PARTUUID ) + + if [ -z "$BLKID" ] + then + echo BLKID still not found, give the kernel one more moment... > /dev/tty1 + sleep 1 + BLKID=$(/sbin/blkid | grep $ROOT_PARTUUID ) + + if [ -z "$BLKID" ] + then + echo FAILED TO FIND BLKID AFTER 2 SECONDS, PLEASE OPEN AN ISSUE WITH A SCREENSHOT OF THIS ERROR > /dev/tty1 + rescue_shell + fi + fi +fi + +echo BLKID: ${BLKID} > /dev/tty1 + #If its an mmcblk device, the kernel partiton will p1. If it is a usb device, the partiton will just be 1 #Just want everything before the 1 ROOT_DEV="${BLKID%1:*}" - -echo ${ROOT_DEV} > /dev/tty1 +echo ROOT_DEV: ${ROOT_DEV} > /dev/tty1 # label any partition on the system with RESCUESHELL to enter the initramfs rescue shell before mount and root_switch. # you can do this with "cgpt add -i 1 -l RESCUESHELL /dev/sda" for example to label the first partiton of a usb drive.