grub.cfg: don't use */? wildcards. they slow down the boot

hardcode everything. in practise, the new logic will work just the same in
almost all cases, for most people, but it works around performance issues in
grub. cleanup of grub.cfg will be done in the next commit
This commit is contained in:
Leah Rowe 2021-12-29 05:58:03 +00:00
parent 0ea263129a
commit c98308c499
1 changed files with 23 additions and 30 deletions

View File

@ -109,16 +109,22 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
search_grub ahci search_grub ahci
search_grub ata search_grub ata
# 2) LVM and RAID which might be used accross multiple devices # 2) LVM and RAID which might be used accross multiple devices
unset lvmvol lvmvol="lvm/matrix-bootvol lvm/matrix-rootvol"
for vol in bootvol rootvol; do # TODO: add more entries to this string in the future, with common
if [ (lvm\/?atrix-${vol}) != "(lvm/?atrix-${vol})" ]; then # Sketchy check, hardcoded string to be dropped in future # volume group names per common distro configs. look at what all the
lvmvol="${lvmvol} (lvm/matrix-${vol})" # popular distros are doing when the user select automatic partitioning
fi # in their distro's installer. this still won't cover all use cases,
done # but grub's enumeration of anything partition-related is very slow,
unset raidvol # so for now we hardcode everything in grub.cfg
if [ (md/?) != "(md/?)" ] ; then
raidvol=(md/?) # again, hardcoded. grub's enumeration is always very slow.
fi # until that is optimized, we must hardcode everything in grub.cfg
raidvol="md/0 md/1 md/2 md/3 md/4 md/5 md/6 md/7 md/8 md/9"
# in practise, doing multiple redundant checks is perfectly fast and
# ok, even if less technically correct
# TODO: optimize grub itself, and use */? here for everything
for vol in ${lvmvol} ${raidvol} ; do for vol in ${lvmvol} ${raidvol} ; do
try_user_config "${vol}" try_user_config "${vol}"
done done
@ -129,22 +135,15 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
# Encrypted disks and partitions # Encrypted disks and partitions
#TODO: This needs to be adjusted on each device to exclude ODD #TODO: This needs to be adjusted on each device to exclude ODD
#TODO: Usually ATA is for odd if both exist! #TODO: Usually ATA is for odd if both exist!
#TODO: Unset variables before use!
#TODO: Pick better variable name scheme than ${ddev}, or find way to make it local
unset ahcidev unset ahcidev
unset atadev unset atadev
if [ (ahci?) != "(ahci?)" ]; then for i in 11 10 9 8 7 6 5 4 3 2 1 0; do
ahcilist=(ahci*) 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 ${ahcilist}; do ahcidev="(ahci${i},${part}) ${ahcidev}"
ahcidev="$part $ahcidev" atadev="(ata${i},${part}) ${atadev}"
done done
fi done
if [ (ata?) != "(ata?)" ]; then
atalist=(ata*)
for part in ${atalist}; do
atadev="$part $atadev"
done
fi
set pager=0 set pager=0
echo -n "Attempting to cryptomount: " echo -n "Attempting to cryptomount: "
for dev in ${ahcidev} ${atadev} ${lvmvol} ${raidvol}; do for dev in ${ahcidev} ${atadev} ${lvmvol} ${raidvol}; do
@ -154,13 +153,7 @@ menuentry 'Load Operating System (incl. fully encrypted disks) [o]' --hotkey='o
set pager=1 set pager=1
echo # Insert newline echo # Insert newline
# Rescan lvm volumes, should probably use test at this point # Retry lvm volumes, because after cryptomount, they might now be exposed
unset lvmvol
for vol in bootvol rootvol; do
if [ (lvm\/?atrix-${vol}) != "(lvm/?atrix-${vol})" ]; then # Sketchy check, hardcoded string to be dropped in future
lvmvol="${lvmvol} (lvm/matrix-${vol})"
fi
done
# 3) LVM inside LUKS containers # 3) LVM inside LUKS containers
for vol in ${lvmvol}; do for vol in ${lvmvol}; do