5

Is there like a default EFI file setting or something. I have a disk drive with Linux on it, and multiple efi files. My computer cant boot into it.I have another disk drive with windows and multiple efi files and even folders. How does uefi decide whoch one the boot into. Is it the first one it comes across or what? Edit: fixed spelling errors

tommy morty
  • 51
  • 1
  • 2

1 Answers1

11

It stores the paths in the motherboard's NVRAM (the same that still gets called "CMOS memory").

The details can be found in the freely-available UEFI Specification (section 3). The EFI NVRAM contains a list of boot option variables named Boot#### (e.g. Boot0001, Boot0002), each of which stores the exact path of a single .efi file – including the partition's GUID.

$ efibootmgr
BootCurrent: 0000
BootOrder: 0000,000F,0001
Boot0000* Linux Boot Manager
    HD(1,GPT,760e363e-[...],0x800,0x80000)/File(\EFI\systemd\systemd-bootx64.efi)
Boot0001* Windows Boot Manager
    HD(1,GPT,760e363e-[...],0x800,0x80000)/File(\EFI\Microsoft\Boot\Bootmgfw.efi)

The boot options aren't used in numerical order, but in the order specified by the BootOrder variable. (The OS can also set BootNext to request EFI to reboot once straight into one of the boot options, or it can set OsIndications to request a reboot into the UEFI setup screen.)

You can see the boot-related EFI variables using:

  • On Linux: efibootmgr (older versions need efibootmgr -v)

    (You can also list all EFI variables through /sys/firmware/efi/efivars/.)

  • On Windows: bcdedit /enum firmware

    Note that the bcdedit output uses Windows BCD-specific terminology and everything looks quite different from the actual EFI variables, but each of the entries still represents one 'Boot####' item – except for {fwbootmgr}, whose "displayorder" parameter represents 'BootOrder'.

  • In the EFI Shell: bcfg boot dump

And if you're booting from removable media (which the NVRAM of course won't know about) – or if you're booting from an internal disk, but none of the BootOrder options worked – the firmware will then look for one specific path in each EFI System Partition – always \EFI\Boot\BootX64.efi on x86_64 systems. (Section "3.5.1.1 Removable Media Boot Behavior" lists names for each CPU architecture.)

Most OS installers place a copy of their bootloader at \EFI\Boot\BootX64.efi to make sure the system still boots into something even if the NVRAM data is lost.

(Finally... some firmwares will automatically look for \EFI\Microsoft\Boot\Bootmgfw.efi, because that's where the Windows Boot Manager is placed. If you're lucky, the firmware will just use this as a 2nd fallback path. Yet there have been UEFI motherboards which insist on only using this path and refuse to boot anything else but Windows.)

grawity
  • 501,077