summaryrefslogtreecommitdiff
path: root/resources/grub
diff options
context:
space:
mode:
authorVitali64 <vitali64pmemail@protonmail.com>2021-12-28 19:23:10 +0100
committerLeah Rowe <leah@libreboot.org>2021-12-29 01:03:18 +0000
commitcff081c6dbdeed721ad5fd59943e9a020a9299af (patch)
treefb823bf6275ada4ed204852c4333c1c2c79f96db /resources/grub
parent72217829404a3ab77d949556417dd0c56dcee256 (diff)
Fix grub's slow boot
On many boards, grub takes a very long time to search for a grub.cfg file on the disk. The problem is the search_grub function which takes a long time to complete. I (vitali64) studied the grub.cfg from 2016 and the grub.cfg from 2021 and optimized the grub.cfg. It should be faster now.
Diffstat (limited to 'resources/grub')
-rw-r--r--resources/grub/config/grub.cfg25
1 files changed, 17 insertions, 8 deletions
diff --git a/resources/grub/config/grub.cfg b/resources/grub/config/grub.cfg
index 37b83728..5cda2329 100644
--- a/resources/grub/config/grub.cfg
+++ b/resources/grub/config/grub.cfg
@@ -47,16 +47,25 @@ function try_user_config {
}
function search_grub {
echo -n "Attempting to load grub.cfg from: "
- unset ddev
- if [ (${1}?) != "(${1}?)" ]; then
- ddev=(${1}*) # Both raw and partitioned devices
- fi
- for i in ${ddev}; do
- echo -n "${i} "
- try_user_config "${i}"
+ # TODO : Find a better way to detect how many disks
+ # : are on the computer instead of hardcoding.
+ # FIXME: Does this work on all boards?
+ for i in 0 1 2 3 4 5 6 7 8 9 10 11; do
+ # TODO : Find a better way to detect how many partitions
+ # : are on the disk instead of hardcoding.
+ echo "\nTrying disk ${1}${i}"
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
+ # MBR/GPT partitions
+ echo "\nTrying partiton ${part}"
+ try_user_config "(${1}${i},${part})"
+ done
+ # raw devices
+ echo "\nTrying to boot to a raw disk ..."
+ try_user_config "(${1}${i})"
+ echo # Insert newline
done
- echo # Insert newline
}
+
function try_isolinux_config {
set root="${1}"
for dir in '' /boot; do