Efibootmgr - hpaluch/hpaluch.github.io GitHub Wiki

Efibootmgr

Linux EFI boot manager - manages UEFI boot entries that are stored in NVRAM (Non-Volatile RAM).

NOTE: many recent UEFI implementations have "autodiscovery" feature - they scan ESP partition for bootloaders and automatically show found entries. However it is good practice to add boot entries using standard tools.

  • listing entries: efibootmgr or efibootmgr -v (different implementations have different details):

    # on SUSE -v is required to get paths:
    
    $ efibootmgr -v
    BootCurrent: 0000
    Timeout: 0 seconds
    BootOrder: 0002,0001,0000,0003
    Boot0000* opensuse-secureboot	HD(1,GPT,da572218-769b-4d2f-af59-a193be758a66,0x800,0x100000)/File(\EFI\opensuse\shim.efi)
    Boot0001* Plan9	HD(1,GPT,09435737-cdb5-46b3-b0fc-c48428df98d8,0x800,0x180000)/File(\EFI\plan9\bootx64.efi)
    Boot0002* FreeBSD	HD(1,GPT,da572218-769b-4d2f-af59-a193be758a66,0x800,0x100000)/File(\EFI\freebsd\loader.efi)
    Boot0003* UEFI OS	HD(4,GPT,a943da0d-4206-45f6-b645-cfb8ecc35145,0x6fc00800,0x4b06000)/File(\EFI\BOOT\BOOTX64.EFI)..BO
    
  • those long identifiers are GPT partition UUIDs, you can get them using fdisk -x /dev/DISK, for example:

$ fdisk -x /dev/sda

Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors Disk model: Samsung SSD 870 Units: sectors of 1 * 512 = 512 bytes ... Disklabel type: gpt ...

Device Start End Sectors Type-UUID UUID Name Attrs /dev/sda1 2048 1574911 1572864 C12A7328-F81F-11D2-BA4B-00A0C93EC93B 09435737-CDB5-46B3-B0FC-C48428DF98D8
/dev/sda2 2099200 1807747071 1805647872 516E7CBA-6ECF-11D6-8FF8-00022D09712B 3D3A9EB1-8499-4EAA-A5B1-142F8571F77B
/dev/sda3 1807747072 1874855935 67108864 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F F5FBC163-B0AD-4056-ADFD-179C085ABE02
/dev/sda4 1874855936 1953523711 78667776 C91818F9-8025-47AF-89D2-F030D7000C2C A943DA0D-4206-45F6-B645-CFB8ECC35145 Plan 9


- second UUID column (named just `UUID`) is that one that must match UUID in `efibootmgr -v` output.
In my case `/dev/sda` has ESP partition `/dev/sda1` and thus partition UUID is `09435737-CDB5-46B3-B0FC-C48428DF98D8`.
So boot entry from `/dev/sda` disk looks like:

Boot0001* Plan9 HD(1,GPT,09435737-cdb5-46b3-b0fc-c48428df98d8,0x800,0x180000)/File(\EFI\plan9\bootx64.efi)


- add entry on default `/dev/sda` disk (path must exists on EFI partition on such disk)

```shell
# EFI partition is expected on /dev/sda (!)
efibootmgr -c -L Plan9 -l '\EFI\plan9\bootx64.efi'
  • if you want to add entry from different disk - typically NVMe you need to specify -d /dev/DISK, in my example:

    efibootmgr -c -L FreeBSD -d /dev/nvme0n1 -l '\EFI\freebsd\loader.efi'
    
  • deleting Boot entry: efibootmgr -b BOOT_NUMBER -B, where BOOT_NUMBER is number extracted from BootXXXX entry.