Fix Broken UEFI Boot Options Using efibootmgr

When a system fails to boot due to missing, corrupted, or reordered UEFI NVRAM entries, the command-line utility efibootmgr provides a direct method to repair these configurations from a Linux live environment. This guide explains how to boot into a live system, inspect the current NVRAM boot variables, remove corrupt or obsolete entries, re-add valid boot paths pointing to installed OS bootloaders, and set the correct boot priority.

Prerequisites: Accessing a Live Environment

To repair an unbootable machine, boot from any modern 64-bit Linux installation media or live USB. The live media must be booted in UEFI mode (not Legacy/CSM) so the kernel can access the system's EFI variables.

Verify that EFI variables are accessible by checking the /sys/firmware/efi/efivars directory:

ls /sys/firmware/efi/efivars

If the directory contains files, your environment is ready. If it is empty or missing, mount the EFI variables manually:

mount -t efivarfs efivarfs /sys/firmware/efi/efivars

Step 1: Inspect Current Boot Entries

Run efibootmgr with the verbose flag to list all registered UEFI boot options, their assigned entry numbers, active status, disk targets, and file paths:

efibootmgr -v

The output will display:

  • BootCurrent: The entry used to boot the current session.
  • BootOrder: The order of preference the firmware follows when booting.
  • BootXXXX: Individual boot options (e.g., Boot0001, Boot0002), indicating whether they are active (*), along with their disk UUID and the exact path to the .efi executable.

Identify whether your desired operating system entry is missing, pointing to an incorrect partition, or missing from the BootOrder list.

Step 2: Remove Stale or Broken Entries

Corrupted, duplicated, or non-functional entries should be removed to prevent boot loops or conflicts.

To delete an entry, pass the entry number using the -b flag and specify -B to delete:

efibootmgr -b 0002 -B

Replace 0002 with the hexadecimal identifier of the broken entry identified in Step 1.

Step 3: Recreate the Missing Boot Entry

If an entry is missing or pointed to an invalid binary, you can manually recreate it using the -c (create) option.

Locate the EFI System Partition (ESP) using lsblk or fdisk -l. Assuming the ESP is /dev/nvme0n1p1 (Disk: /dev/nvme0n1, Partition: 1):

efibootmgr -c -d /dev/nvme0n1 -p 1 -L "Linux Boot Manager" -l '\EFI\systemd\systemd-bootx64.efi'

Key arguments:

  • -c: Creates a new entry.
  • -d /dev/nvme0n1: Specifies the target physical disk containing the ESP.
  • -p 1: Specifies the partition number of the ESP on that disk.
  • -L "Label": Sets the user-visible label in the UEFI boot menu.
  • -l '\EFI\path\to\loader.efi': Sets the path to the bootloader binary. Note: UEFI uses backslashes (\) for file paths. In Linux shells, wrap the path in single quotes to prevent backslash escaping.

Common loader paths:

  • GRUB (Ubuntu/Debian): '\EFI\ubuntu\shimx64.efi' or '\EFI\ubuntu\grubx64.efi'
  • GRUB (Fedora): '\EFI\fedora\shimx64.efi'
  • systemd-boot: '\EFI\systemd\systemd-bootx64.efi'
  • Windows Boot Manager: '\EFI\Microsoft\Boot\bootmgfw.efi'

Step 4: Configure the Boot Order

Creating a new entry automatically sets it as the first item in the boot sequence, but you should verify or manually redefine the order using the -o flag:

efibootmgr -o 0003,0001,0000

List the entry numbers in your desired priority order, separated by commas without spaces.

Step 5: Activate and Test the Configuration

Ensure the target entry is active. If an entry does not have an asterisk next to it in efibootmgr -v, activate it explicitly:

efibootmgr -b 0003 -a

Run efibootmgr one last time without arguments to confirm the BootOrder and boot entries match your configuration:

efibootmgr

Once confirmed, remove the live USB media and reboot the machine:

reboot