grub.cfg patch from shmalebx9: reverse search order for encrypted partitions

Also, when a cryptomount is successful, break from the loop and boot from that.
In most cases, this will work just fine, and this change improves the boot
speed in the vast majority of cases.

From <https://notabug.org/libreboot/lbmk/issues/53>

This is based on commit 5767489cadc4a9a1f2e7bffe03457e29e1c9a101 from
https://github.com/shmalebx9/Bleeding-Libreboot/
This commit is contained in:
Leah Rowe 2021-10-30 16:03:10 +01:00
parent 777316eb4f
commit f195282d90
1 changed files with 10 additions and 4 deletions

View File

@ -113,17 +113,22 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
# Encrypted disks and partitions
#TODO: This needs to be adjusted on each device to exclude ODD
#TODO: Usually ATA is for odd if both exist!
#TODO: Shouldn't it stop at first successful cryptomount?
#TODO: Unset variables before use!
#TODO: Pick better variable name scheme than ${ddev}, or find way to make it local
unset ahcidev
unset atadev
unset usbdev
if [ (ahci?) != "(ahci?)" ]; then
ahcidev=(ahci*)
ahcilist=(ahci*)
for part in ${ahcilist}; do
ahcidev="$part $ahcidev"
done
fi
if [ (ata?) != "(ata?)" ]; then
atadev=(ata*)
atalist=(ata*)
for part in ${atalist}; do
atadev="$part $atadev"
done
fi
if [ (usb?) != "(usb?)" ]; then
usbdev=(usb*)
@ -132,7 +137,7 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
echo -n "Attempting to cryptomount: "
for dev in ${usbdev} ${ahcidev} ${atadev} ${lvmvol}; do # what about raid?
echo -n "${dev} "
cryptomount "${dev}"
if cryptomount "${dev}" ; then break ; fi
done
set pager=1
echo # Insert newline
@ -179,6 +184,7 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
true # Prevent pager requiring to accept each line instead of whole screen
}
menuentry 'Search ISOLINUX menu (AHCI) [a]' --hotkey='a' {
search_isolinux ahci
}