grub.cfg: skip ata/ahci according to grub_scan_disk

logic for setting it in grub.cfg will be done in the next commit
fsdg20230625
Leah Rowe 2021-12-29 06:55:07 +00:00
parent 9b1499fd1e
commit 835ff5ec83
1 changed files with 36 additions and 22 deletions

View File

@ -28,6 +28,7 @@ fi
set default="0"
set timeout=10
set pager=1
set grub_scan_disk="both"
keymap usqwerty
function try_user_config {
@ -75,8 +76,13 @@ function search_isolinux {
echo # Insert newline
}
menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' {
search_grub ahci
search_grub ata
if [ "${grub_scan_disk}" != "ata" ]; then
search_grub ahci
fi
if [ "${grub_scan_disk}" != "ahci" ]; then
search_grub ata
fi
# grub device enumeration is very slow, so checks are hardcoded
@ -97,8 +103,12 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
unset atadev
for i in 11 10 9 8 7 6 5 4 3 2 1 0; do
for part in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1; do
ahcidev="(ahci${i},${part}) ${ahcidev}"
atadev="(ata${i},${part}) ${atadev}"
if [ "${grub_scan_disk}" != "ata" ]; then
ahcidev="(ahci${i},${part}) ${ahcidev}"
fi
if [ "${grub_scan_disk}" != "ahci" ]; then
atadev="(ata${i},${part}) ${atadev}"
fi
done
done
@ -117,27 +127,31 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
search_grub crypto
# Last resort, if all else fails
set root=ahci0,1
for p in / /boot/; do
if [ -f "${p}vmlinuz" ]; then
linux ${p}vmlinuz root=/dev/sda1 rw
if [ -f "${p}initrd.img" ]; then
initrd ${p}initrd.img
if [ "${grub_scan_disk}" != "ata" ]; then
# Last resort, if all else fails
set root=ahci0,1
for p in / /boot/; do
if [ -f "${p}vmlinuz" ]; then
linux ${p}vmlinuz root=/dev/sda1 rw
if [ -f "${p}initrd.img" ]; then
initrd ${p}initrd.img
fi
fi
fi
done
done
fi
# Last resort (for setups that use IDE instead of SATA)
set root=ata0,1
for p in / /boot/; do
if [ -f "${p}vmlinuz" ]; then
linux ${p}vmlinuz root=/dev/sda1 rw
if [ -f "${p}initrd.img" ]; then
initrd ${p}initrd.img
if [ "${grub_scan_disk}" != "ahci" ]; then
# Last resort (for setups that use IDE instead of SATA)
set root=ata0,1
for p in / /boot/; do
if [ -f "${p}vmlinuz" ]; then
linux ${p}vmlinuz root=/dev/sda1 rw
if [ -f "${p}initrd.img" ]; then
initrd ${p}initrd.img
fi
fi
fi
done
done
fi
true # Prevent pager requiring to accept each line instead of whole screen
}