Efibootmgr
efibootmgr[1] is a command line tool to managing UEFI boot menu.
Usage
Assumming that you have installed Linux in UEFI mode.
Install efibootmgr
You can install the efibootmgr command line utility with the following commands on Debian/Ubuntu/Linux Mint
sudo apt install efibootmgr
Displaying Current Settings
Simply run the following command. In some Linux distributions like Debian, you need to run it with sudo
privilege.
$ efibootmgr
BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0002,0009,0003,0001,0007,0004
Boot0000* AMIFWUpdate
Boot0001* UEFI: Built-in EFI Shell
Boot0002* ubuntu
Boot0003* USB
Boot0004* CentOS Linux
Boot0007* CentOS Linux
Boot0009* Hard Drive
MirrorStatus: Platform does not support address range mirror
DesiredMirroredPercentageAbove4G: 0.00
DesiredMirrorMemoryBelow4GB: false
#-v
option to show verbose information
$ efibootmgr -v
BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0002,0009,0003,0001,0007,0004
Boot0000* AMIFWUpdate
Boot0001* UEFI: Built-in EFI Shell
Boot0002* ubuntu
Boot0003* USB
Boot0004* CentOS Linux
Boot0007* CentOS Linux
Boot0009* Hard Drive
MirrorStatus: Platform does not support address range mirror
DesiredMirroredPercentageAbove4G: 0.00
DesiredMirrorMemoryBelow4GB: false
hpcmate@GPGPUA:~/setup/test$ efibootmgr -v
BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0002,0009,0003,0001,0007,0004
Boot0000* AMIFWUpdate VenMedia(5023b95c-db26-429b-a648-bd47664c8012)/FvFile(1de64b8e-138b-4258-b7dd-f2d8ec142a9e)
Boot0001* UEFI: Built-in EFI Shell VenMedia(5023b95c-db26-429b-a648-bd47664c8012)..BO
Boot0002* ubuntu HD(1,GPT,eac04fbf-cb5f-4e94-a04f-b0e250c06b62,0x800,0x100000)/File(\EFI\UBUNTU\SHIMX64.EFI)
Boot0003* USB BBS(USB,,0x0)..GO..NO........c.A.M.I. .V.i.r.t.u.a.l. .C.D.R.O.M.0. .1...0.0............?........A........................?.....0..Gd-.;.A..MQ..L.A.A.A.A.B.B.B.B.C.C.C.C.1...?.....BO
Boot0004* CentOS Linux VenHw(99e275e7-75a0-4b37-a2e6-c5385e6c00cb)
Boot0007* CentOS Linux VenHw(99e275e7-75a0-4b37-a2e6-c5385e6c00cb)
Boot0009* Hard Drive BBS(HD,,0x0)..GO..NO........o.S.a.m.s.u.n.g. .S.S.D. .8.7.0. .E.V.O. .2.T.B............?........A......................?.....>..Gd-.;.A..MQ..L.7.S.4.5.S.N.W.0.0.A.7.8.3.3. .P. . . . ...?.....BO
MirrorStatus: Platform does not support address range mirror
DesiredMirroredPercentageAbove4G: 0.00
DesiredMirrorMemoryBelow4GB: false
Changing Boot Order
First, copy the current boot order. For example, my boot order is:
0002,0009,0003,0001,0007,0004
Then type in the following command
sudo efibootmgr -o
And append the boot order to the above command.
sudo efibootmgr -o 0002,0009,0003,0001,0007,0004
Let’s say you want 0009
to be the first boot entry. All you have to do is move it to the left of 0002
and press Enter.
sudo efibootmgr -o 0009,0002,0003,0001,0007,0004
Adding Boot Entry
If you have installed multiple Linux distributions on your computer, but one of the Linux distribution doesn’t have a UEFI boot entry, you can manually add it. Boot into the Linux distro that doesn’t have UFEI boot entry. Then make sure it has the EFI version of GRUB boot loader installed.
Debian/Ubuntu/Linux Mint
sudo apt install grub-efi
Then mount the EFI system partition (ESP) under /boot/efi/
directory. In this example, /dev/sda1
is the ESP. ** If you are using NVME SSD, then the disk name is different. Use the following command to check the disk name.
sudo mount /dev/sda1 /boot/efi/
Then install Grub boot loader to ESP.
sudo grub-install /dev/sda --target=x86_64-efi --efi-directory=/boot/efi/
x86_64-efi
means that we are going to install Grub for UEFI firmware. The default target is i386-pc
, which is for traditional BIOS firmware.
Now, you should see a new entry in UEFI boot menu with the bootmgr
command. Under the hood, the Grub installer first installs a .efi
booloader file to /boot/efi/EFI/<label>/
directory. Usually it’s named grubx64.efi. Then it runs the following command to add a new entry in UEFI boot menu.
efibootmgr -c -d /dev/sda -p 7 -L <label> -l \EFI\<label>\grubx64.efi
Newly added entry will be the first in boot order.
Deleteing Boot Entry
To remove the respective boot entry, run:
sudo efibootmgr -b <bootnum> -B
For example,
sudo efibootmgr -b 0014 -B
-b
option specify the boot number. -B
option delete that boot number.
Setting a Boot Entry Active or Inactive
A boot entry followed by an asterisk indicates that it’s active from the output of efibootmgr command. Otherwise it’s inactive.
To set a boot entry active, run:
sudo efibootmgr -b <bootnum> -a
To set a boot entry inactive, run:
sudo efibootmgr -b <bootnum> -A
We can use systemd service to automatically disable target boot entry.
sudo nano /etc/systemd/system/disable-boot-entry.service
Add the following line in this file.
[Unit] Description=disable Linux Mint Boot Entry After=multi-user.target [Service] Type=oneshot ExecStart=/bin/bash -c '/usr/bin/efibootmgr -b <Target boot entry number> -A' [Install] WantedBy=multi-user.target