grub.cfg: skip ata/ahci according to grub_scan_disk

logic for setting it in grub.cfg will be done in the next commit
This commit is contained in:
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 default="0"
set timeout=10 set timeout=10
set pager=1 set pager=1
set grub_scan_disk="both"
keymap usqwerty keymap usqwerty
function try_user_config { function try_user_config {
@ -75,8 +76,13 @@ function search_isolinux {
echo # Insert newline echo # Insert newline
} }
menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' { menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o' {
if [ "${grub_scan_disk}" != "ata" ]; then
search_grub ahci search_grub ahci
fi
if [ "${grub_scan_disk}" != "ahci" ]; then
search_grub ata search_grub ata
fi
# grub device enumeration is very slow, so checks are hardcoded # 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 unset atadev
for i in 11 10 9 8 7 6 5 4 3 2 1 0; do 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 for part in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1; do
if [ "${grub_scan_disk}" != "ata" ]; then
ahcidev="(ahci${i},${part}) ${ahcidev}" ahcidev="(ahci${i},${part}) ${ahcidev}"
fi
if [ "${grub_scan_disk}" != "ahci" ]; then
atadev="(ata${i},${part}) ${atadev}" atadev="(ata${i},${part}) ${atadev}"
fi
done done
done done
@ -117,6 +127,7 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
search_grub crypto search_grub crypto
if [ "${grub_scan_disk}" != "ata" ]; then
# Last resort, if all else fails # Last resort, if all else fails
set root=ahci0,1 set root=ahci0,1
for p in / /boot/; do for p in / /boot/; do
@ -127,7 +138,9 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
fi fi
fi fi
done done
fi
if [ "${grub_scan_disk}" != "ahci" ]; then
# Last resort (for setups that use IDE instead of SATA) # Last resort (for setups that use IDE instead of SATA)
set root=ata0,1 set root=ata0,1
for p in / /boot/; do for p in / /boot/; do
@ -138,6 +151,7 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
fi fi
fi fi
done done
fi
true # Prevent pager requiring to accept each line instead of whole screen true # Prevent pager requiring to accept each line instead of whole screen
} }