How To Get Ubuntu To Boot Before Windows Using The EFI Boot Manager

Ubuntu
Ubuntu.

Introduction

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

This guide shows you how to get your computer to show a menu with options for booting into either Ubuntu or Windows.

Boot Into A Live Version Of Linux

In order to follow this guide you will need to boot into a live version of Linux.  

  1. Insert the USB or DVD which you used to install Linux into your computer. 
  2. Boot into Windows
  3. Hold down the shift key and restart the system (keep the shift key held down)
  4. When the blue screen appears click on the option for booting to 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

This guide will show you how to use EFI Boot Manager which lets you manipulate the boot order so that you can boot into Linux and Windows.

  1. Open a terminal window by pressing CTRL, ALT and 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, Zorin etc 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, Antergos etc use the pacman command:

    sudo pacman -S efibootmgr


    How To Find Out The Current Boot Order

    To find out the order in which systems will 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 in order to use efibootmgr.

     

    The output will be 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

    So what does this tell us.

    The BootCurrent line shows which of the boot options was used this time around. In my case it was actually Linux Mint but Linux Mint is a derivative of Ubuntu and so 0004 = ubuntu.

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

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

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

    If the order was 2001,0006,0001 then the system would try to load from a USB drive and if there weren't any 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 it booting first then you will 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 hopefully 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 not only 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 then they won't be listed as part of the boot order. This means 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 try to 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 will set a timeout of 10 seconds. After the time has run out the default boot option will be 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 back to just one system then you will need to adjust the boot order so that the one you are deleting isn't first in the list and you will 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 would first change the boot order as follows:

    sudo efibootmgr -o 2001,6,1

    You would 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

    Further Reading

    There are further commands which would be used by OS installers to create boot menu options in the first place and for system administrators to create network boot options.

    You can find out more about these by reading the manual pages for EFI Boot Manager using the following command:

    man efibootmgr

    More From Us