How to Get Ubuntu to Boot Before Windows Using the EFI Boot Manager

Ubuntu

 Ubuntu

If you recently installed Ubuntu alongside Windows or any other version of Linux alongside Windows, then you may have come across an issue where the computer boots into Windows without an option for booting into Linux. This is a common side effect of computers with the EFI Boot Manager.

You can get your computer to show a menu with options for booting into either Ubuntu or Windows.

Boot Into a Live Version of Linux

To follow this guide, you need to boot into a live version of Linux

  1. Insert the USB drive or DVD that you used to install Linux on your computer. 

  2. Boot into Windows.

  3. Hold down the Shift key and restart the system while holding down the Shift key.

  4. When the screen appears, click on the option for booting from a USB device or DVD.

  5. Linux should now load into the live version of the operating system in the same way it did when you first installed it.

How to Install EFI Boot Manager

Here's how to use EFI Boot Manager to manipulate the boot order so you can choose to boot into Linux or Windows.

  1. Open a terminal window by pressing Ctrl+ALT+T at the same time.

  2. Run the appropriate command for installing the EFI boot manager based on the Linux distribution you are using:

For Ubuntu, Linux Mint, Debian, and Zorin, use the apt-get command:

sudo apt-get install efibootmgr

For Fedora and CentOS, use the yum command:

sudo yum install efibootmgr

For openSUSE:

sudo zypper install efibootmgr

For Arch, Manjaro, and Antergos, use the pacman command:

sudo pacman -S efibootmgr

How to Find Out the Current Boot Order

To find out the order in which systems load, type the following command:

sudo efibootmgr

The sudo part of the command elevates your permissions to that of the root user which is required when using efibootmgr. You must be the root user to use efibootmgr. 

The output looks something like this:

  • BootCurrent: 0004
  • Timeout: 0 seconds
  • BootOrder: 0004,0001,0002,0005,0006,2001
  • Boot0001 Windows Boot Manager
  • Boot0002 Network
  • Boot0004 ubuntu
  • Boot0005 Hard Drive
  • Boot0006 CD/DVD/CD-RW Drive
  • Boot2001 EFI USB Device

The BootCurrent line shows which of the boot options was used this time around. In this example, 0004 is Ubuntu.

The Timeout tells you how long the menu appears before the first boot option is chosen. It defaults to 0.

The BootOrder shows the order in which each option will be loaded. The next item in the list is chosen if the preceding item fails to load. 

In the example, the system is going to boot 0004 first which is Ubuntu, then 0001 which is Windows, 0002 networks, 0005 hard drive, 0006 CD/DVD drive, and finally 2001 which is the USB drive.

If the order were 2001,0006,0001, the system would try to load from a USB drive. If no USB drive were present, it would boot from the DVD drive, and finally, it would boot Windows.

How to Change the EFI Boot Order

The most common reason to use the EFI Boot Manager is to change the boot order. If you have installed Linux and for some reason Windows is booting first, then you need to find your version of Linux in the boot list and make it boot before Windows.

For example, take this list:

  • BootCurrent: 0001
  • Timeout: 0 seconds
  • BootOrder: 0001,0004,0002,0005,0006,2001
  • Boot0001 Windows Boot Manager
  • Boot0002 Network
  • Boot0004 ubuntu
  • Boot0005 Hard Drive
  • Boot0006 CD/DVD/CD-RW Drive
  • Boot2001 EFI USB Device

You should be able to see that Windows boots first because it is assigned to 0001, which is first in the boot order.

Ubuntu won't load unless Windows fails to boot because it is assigned to 0004 which comes after 0001 in the boot order list.

It is a good idea to place Linux, the USB drive, and DVD drive before Windows in the boot order. 

To change the boot order so that the USB drive is first, then the DVD drive, followed by Ubuntu and finally Windows you would use the following command.

sudo efibootmgr -o 2001,0006,0004,0001

You can use a shorter notation as follows:

sudo efibootmgr -o 2001,6,4,1

The boot list should now look like this:

  • BootCurrent: 0001
  • Timeout: 0 seconds
  • BootOrder: 2001,0006,0004,0001
  • Boot0001 Windows Boot Manager
  • Boot0002 Network
  • Boot0004 ubuntu
  • Boot0005 Hard Drive
  • Boot0006 CD/DVD/CD-RW Drive
  • Boot2001 EFI USB Device

Note that if you fail to list all the possible options, they won't be listed as part of the boot order. This example shows that 0002 and 0005 will be ignored.

How to Change the Boot Order for the Next Boot Only

If you want to temporarily make it so the next boot of the computer uses a specific option, use the following command:

sudo efibootmgr -n 0002
  • BootCurrent: 0001
  • Timeout: 0 seconds
  • BootOrder: 2001,0006,0004,0001
  • Boot0001 Windows Boot Manager
  • Boot0002 Network
  • Boot0004 ubuntu
  • Boot0005 Hard Drive
  • Boot0006 CD/DVD/CD-RW Drive
  • Boot2001 EFI USB Device

Using the above list this would mean the next time the computer boots, it will boot from the network.

If you change your mind and you want to delete the next boot option, then run the following command to cancel it.

sudo efibootmgr -N

Setting a Timeout

If you want to be able to choose from a list each time your computer loads then you can specify a timeout.

To do this enter the following command:

sudo efibootmgr -t 10

The above command sets a timeout of 10 seconds. After the time has run out, the default boot option is chosen.

You can delete the timeout using the following command:

sudo efibootmgr -T

How to Delete a Boot Menu Item

If you have dual-booted your system and you want to revert to just one system, then you need to adjust the boot order so that the one you are deleting isn't first on the list. You want to remove the item from the boot order altogether.

  • BootCurrent: 0001
  • Timeout: 0 seconds
  • BootOrder: 2001,0006,0004,0001
  • Boot0001 Windows Boot Manager
  • Boot0002 Network
  • Boot0004 ubuntu
  • Boot0005 Hard Drive
  • Boot0006 CD/DVD/CD-RW Drive
  • Boot2001 EFI USB Device

If you have the above boot options and you wanted to remove Ubuntu, then you first change the boot order as follows:

sudo efibootmgr -o 2001,6,1

Then delete the Ubuntu boot option with the following command:

sudo efibootmgr -b 4 -B

The first -b selects the boot option 0004, and the -B deletes the boot option.

You can use a similar command to make a boot option inactive as follows:

sudo efibootmgr -b 4 -A

You can make the boot option active again by using this command:

sudo efibootmgr -b 4 -a