When we install a new Linux, the installer will install a bootloader (efi file) at EFI partition and update the menu entry at NVRAM, and most likely set the newly added bootloader as default. The bootloader will read the /boot/grub/grub.cfg to load the kernel and initrd.

My question is, when there are multiple bootloaders (.efi) reside in ESP, are they identical? Since they are all GRUB2. Can each of them discover all the kernels in the system?

Since each OS's partition has /boot/grub/grub.cfg file, which one is being read by the default bootloader?


My question is, when there are multiple bootloaders (.efi) reside in ESP, are they identical? since they are all grub2. Can all of them discover all the kernel in the system?

If there are multiple UEFI Linux installations on a disk, they normally use the same EFI System Partition (ESP), but their respective EFI executables live in different subdirectories of the ESP, of the form EFI/bootloader-id. The EFI executables have the same name; for 64 bit installations it is grubx64.efi. So the EFI variables would be located at EFI/bootloader-id/grubx64.efi

These executables are installed by grub-install running on their respective systems, though you might have to point grub-install to that partition using --efi-directory. And you may also have to choose the value of bootloader-id with --bootloader-id. Different Linux distributions have different defaults for bootloader-id. For example, Debian defaults to debian. For more information about grub-install options, see man grub-install.

grub-install hard-wires the name of the boot/root devices into those executables using UUIDs.

These EFI executables are executed by the EFI firmware on the motherboard. Since the EFI executable knows the boot/root devices for its Linux installation, and since, by definition, grub.cfg has a fixed location relative to the boot/root devices, the EFI executable can execute the /boot/grub/grub.cfg corresponding to that installation. And grub.cfg of course has all the information needed to do a boot, including the names of the kernels installed on the system.

The Arch Wiki GRUB page has good coverage of these matters. See also the Debian Wiki UEFI page.

| improve this answer | |
  • very good explanation. From what I understand, the EFI/bootloader-id/grubx64.efi points to a kernel partition and execute grub.cfg when boot. For each EFI/bootloader-id/grubx64.efi, they also can boot other kernel. For example, EFI/ubuntu/grubx64.efi can display the menu including ubuntu and Fedora. EFI/fedora/grubx64.efi can also boot ubuntu and Fedora, since they all using grub2, and grub.cfg has the knowledge where are other kernel located. – user3346398 Jul 19 '17 at 7:05
  • 1
    @user3346398 Yes, the grub.cfg menu may display boot entries about other distributions (that it knows about) that are installed on the machines. I'm not sure how GRUB collects this information, and of course, update-grub corresponding to that grub.cfg would need to be run after the distribution in question was installed, otherwise no new entry would appear. There's also no guarantee that those other entries would be correct - GRUB maybe be operating with imperfect/incomplete information. – Faheem Mitha Jul 19 '17 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.