Skip to content

Commit cb3245f

Browse files
committed
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
1 parent 5f2b999 commit cb3245f

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

initramfs/resources/initramfs-init

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,38 @@ mount -n -t devtmpfs devtmpfs /dev
6565

6666
# get the root device, so we can find the boot partiton
6767
UNPARSED=$(cmdline root)
68+
echo Unparsed cmdline rootdev: ${UNPARSED} > /dev/tty1
6869
ROOT_PARTUUID=$(rootpartuuid $UNPARSED)
69-
echo ${ROOT_PARTUUID} > /dev/tty1
70+
echo ROOT_PARTUUID: ${ROOT_PARTUUID} > /dev/tty1
71+
7072
BLKID=$(/sbin/blkid | grep $ROOT_PARTUUID )
71-
echo ${BLKID} > /dev/tty1
73+
echo BLKID: ${BLKID} > /dev/tty1
74+
if [ -z "$BLKID" ]
75+
then
76+
echo BLKID wasnt found yet, give the kernel a moment... > /dev/tty1
77+
sleep 1
78+
BLKID=$(/sbin/blkid | grep $ROOT_PARTUUID )
79+
80+
if [ -z "$BLKID" ]
81+
then
82+
echo BLKID still not found, give the kernel one more moment... > /dev/tty1
83+
sleep 1
84+
BLKID=$(/sbin/blkid | grep $ROOT_PARTUUID )
85+
86+
if [ -z "$BLKID" ]
87+
then
88+
echo FAILED TO FIND BLKID AFTER 2 SECONDS, PLEASE OPEN AN ISSUE WITH A SCREENSHOT OF THIS ERROR > /dev/tty1
89+
rescue_shell
90+
fi
91+
fi
92+
fi
93+
94+
echo BLKID: ${BLKID} > /dev/tty1
95+
7296
#If its an mmcblk device, the kernel partiton will p1. If it is a usb device, the partiton will just be 1
7397
#Just want everything before the 1
7498
ROOT_DEV="${BLKID%1:*}"
75-
76-
echo ${ROOT_DEV} > /dev/tty1
99+
echo ROOT_DEV: ${ROOT_DEV} > /dev/tty1
77100

78101
# label any partition on the system with RESCUESHELL to enter the initramfs rescue shell before mount and root_switch.
79102
# you can do this with "cgpt add -i 1 -l RESCUESHELL /dev/sda" for example to label the first partiton of a usb drive.

0 commit comments

Comments
 (0)