You are not logged in.
I dont know if this is the right place to ask this kind of question but I want to know more about the booting process with UEFI firmware + GRUB2 and since I had an hard time to understand this piece of the process, here I am:
assuming a simple partition table like:
esp parition fat32 `/dev/sda1` mounted at `/boot`
linux fs ext4 `/dev/sda2` mounted at `/` (root)
/boot/ usually contains:
- ./EFI/BOOT/BOOTX64.efi (uefi fallback)
- ./EFI/GRUB/grubx64.efi (proper grub efi application)
- ./grub/ directory with grub.cfg and stuff
- ./initramfs images
- ./vmlinuz kernels
I understand that the firmware is instructed by efibootmgr to load and execute a specific efi application on a specific device,partition and path
for example: # efibootmgr -c -d /dev/sda -p 1 -l '\EFI\GRUB\grubx64.efi' -L GRUB
Q1: but how grubx64.efi knows how to behave once it is started? how it knows where to look for its config file (i assume grub efi app reads the /boot/grub/grub.cfg)
Q2: what happens if the esp partition, /boot partition and /root partition are 3 different partitions mounted accordingly?
Last edited by kuolemaaa (2025-05-09 11:06:02)
Offline
That information is embedded into the executable by grub-install.
Offline
Embedded configuration. You can check `strings -w grubx64.efi` if you can find it in there somewhere. Usually the UUID of the partition with the Grub config and modules. All modules necessary to reach it also embedded (you can specify more modules to embed at grub-install time.)
Grub also keeps a copy of the configuration it embeds in /boot/grub/*/load.cfg, however editing this file is useless since its re-generated everytime you run grub-install.
Offline
At this point, I guess, grubx64.efi is an efi application that is (sort of) parameterized and compiled every time grub-install is launched?
Offline
Basically, yes.
Offline
Thank you all. Marking it as solved. But if you have resources in order to learn in depth this mechanism I am glad to look at them.
Offline
GRUB is opensource. Unlikely you'll find a detailed description how it works except in its source code.
Offline
a start could be: https://github.com/rhboot/grub2/blob/ma … -install.c
as already mentioned: everytime grub-install is run a new binary is formed (this is true for non-efi i386 legacy, uefi, other platforms supported by grub) which includes required information where to load grub.cfg from and all stuff required to access it
tldr: unless you actively developing low level like design your own hardware and how to bring it up from cold to a running kernel all you need to know is where grub.cfg has to be placed according to the parameters given to grub-install and run grub-mkconfig afterwards
HOW all that the magic works isn't something one has to understand to just use it
Offline