How does the GRUB2 UEFI loader know where to look for the configuration file (or where the 2nd stage's files are located)?
If I use GRUB2 on a GPT-enabled partition how does loader "know" where to find its configuration file and other 2nd stage's files?
Note: I found some mentions about a config file which is located in the same folder as GRUB's EFI loader and contains chained load of "primary" configuration file from the specified partition, but that definitely is not true - there is only one "something.efi" file.
Load a config file in the same directory as the GRUB binary.
Load a config file from a path decided at grub-mkimage (called by grub-install) execution time.
The latter is probably the functionality you are really asking for - and it's a combination of the default config file name (grub.cfg), the prefix (default /boot/grub, but can be explicitly specified to grub-mkimage) and the grub partition name for the partition where the prefix is located.
If I run strings /boot/efi/EFI/debian/grubx64.efi | tail -1 on my current workstation, it prints out the stored value: (,gpt2)/boot/grub, telling grubx64.efi to look for its configuration file in /boot/grub on GPT partition 2. The bit before the comma (the GRUB disk device name) gets filled in at runtime based on which disk the grubx64.efi image itself was loaded from.
Dynamically loaded modules will also be searched for under this location, but in an architecture/platform-specific directory - in this case /boot/grub/x86_64-efi.
Asked in February 2016Viewed 3,325 timesVoted 6Answered 1 times