General Computing
linux boot grub bootloader
Updated Sat, 02 Jul 2022 03:13:01 GMT

How does UEFI know which bootloader configuration to use

It's been a while since I read about UEFI and forgot how some pieces connect. I forgot how UEFI and the Grub bootloader work together. I'll say what I recall, please correct me if I'm wrong:

  • UEFI is OS independent and works by having a single ESP partition no matter the amount of disks.
  • The ESP partition is where new operating systems will "subscribe" themselves to the UEFI process by adding their bootloaders and partition references in their own folders. Basically there's one folder in /boot/efi for each OS that is installed.
  • Bootloaders are stored in NVRAM as a sequence.

Right now I'm using a machine that has Ubuntu, Windows and Arch. Every OS has its bootloader but whenever my machine shows me the "boot entries" I'm actually looking at Ubuntu's Grub configuration. It's like I'm using Ubuntu's grub to load any of the operating systems in my machine.

So the question is: How does UEFI know that Ubuntu is my "main" bootloader. Why am I not presented with the Windows or Arch bootloaders whenever I start my machine?


UEFI is system firmware and GRUB is a bootloader built to conform to the firmware.

GRUB with BIOS takes the form of boot code inside the MBR and before the first partition. With UEFI, GRUB can take the form of the single grubx64.efi file within the ESP partition. GRUB architecture identifiers are for BIOS i386-pc and for UEFI on 64-bit x86 hardware x86_64-efi.

UEFI knows nothing - it will usually just present a menu for the bootloaders that it finds. It won't present the menu if it finds only one bootloader, and will then boot that one without asking questions.

In your case, Grub is evidently the only bootloader present, so it is executed immediately on boot.

There are two methods for Grub to be chosen for boot by the EFI firmware :

  1. UEFI boot variables stored in system NVRAM. In Linux, you can edit them with efibootmgr; in Windows bcdedit /enum FIRMWARE can list them and then edit them.

  2. When UEFI boot variables are not defined, UEFI firmware looks for bootloaders inside the ESP partition. In your case it might find \EFI\boot\bootx64.efi for 64-bit hardware.

Comments (4)

  • +0 – I just realized I can switch bootloaders by changing the boot sequence in my BIOS. Right now the Ubuntu partition is first in the sequence, so it loads the Ubuntu's grubloader. I set the Windows partition as the first in the sequence and the Windows Boot Manager was used instead after a restart.This seems strange, I didn't expect sequence order to matter in UEFI. Any idea why boot sequence matters to change between bootloaders? I thought UEFI was going to pick the booloader based on some other configuration. — Jun 26, 2022 at 09:28  
  • +0 – This depends on your BIOS version and its settings. Not all firmwares are the same, as tailored by the manufacturers. Your BIOS might have a boot-order list, where disks and partitions can appear and it will boot the first valid one that it finds. — Jun 26, 2022 at 09:42  
  • +0 – If the BIOS firmware is a variable, are the "standard" interfaces that work regardless of it the "efibootmgr" and "bcdedit" commands? — Jun 26, 2022 at 09:51  
  • +0 – These are the most-used tools that are built-in to the operating system, but there are others. — Jun 26, 2022 at 10:00