Embed Configurations
This is for cross-linking other grub.cfg
files into your booted grub.cfg
file. This is useful for maintaining/modularizing independent grub.cfg
files. There are 2 ways to do it:
- by
prefix
environment variable - by
configfile
command (direct reading)
Set Prefix and Normal Command
Set Prefix and Normal Command
The first method is to use the prefix
environment variable. First you search the UUID using search.fs_uuid
command. Then you set prefix
variable and perform normal command to load.
insmod search_fs_uuid
search.fs_uuid <UUID> root
set prefix=($root)/boot/grub
normal
Configfile Command
Configfile Command
Another way is to read the config file directly after setting the prefix
variable. Then, we use configfile
to read the configuration file directly. This is the more common implementation compared to normal command:
search.fs_label grub root
if [ -e /boot/grub/example/test1.cfg ]; then
set prefix=($root)/boot/grub
configfile /boot/grub/example/test1.cfg
else
if [ -e /boot/grub/example/test2.cfg ]; then
set prefix=($root)/boot/grub
configfile /boot/grub/example/test2.cfg
else
echo "Could not find an example configuration file!"
fi
fi
That's all about embedding multiple grub.cfg
.