Skip to content

Commit

Permalink
Sometime when booting from USB the kernel doesn't enumerate devices f…
Browse files Browse the repository at this point in the history
…ast enough, leaving us unable to find

the device we are booting from. Give the kernel some time. Fixes #255
  • Loading branch information
SolidHal committed Dec 9, 2020
1 parent 5f2b999 commit cb3245f
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions initramfs/resources/initramfs-init
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cb3245f

Please sign in to comment.