- How to Change Boot Order on Linux
- Ways to Change Boot Order
- Edit GRUB Config File
- Use EFI Boot Manager
- Change via BIOS/UEFI
- SYNOPSIS
- DESCRIPTION
- OPTIONS
- EXAMPLES
- Displaying the current settings (must be root):
- Creating a new boot option
- Changing the boot order
- Changing the boot order for the next boot only
- Deleting a boot option
- Creating network boot entries
- BUGS
- AUTHOR
How to Change Boot Order on Linux
After setting up a dual-boot system, the secondary OS often becomes the default boot option. That’s just one common scenario, but regardless of the exact reasoning, configuring the boot options in Linux is pretty easy.
Linux distros use the GRUB boot loader. As such, you can edit the GRUB config file to set a specific boot entry as the default one. For UEFI systems specifically, the efibootmgr tool works as well.
Or, if you don’t need a Linux-specific solution, you can also change the boot order via the BIOS/UEFI. We’ve covered all these methods with full steps in this article.
Ways to Change Boot Order
The steps covered were tested on Ubuntu, but they’re applicable to most other distros as well. The only thing that might slightly differ is the location of the GRUB config file.
Edit GRUB Config File
You can change the default boot entry on Linux systems by editing the GRUB configuration file. There are various GRUB config files but the one at /etc/default/grub is used for user customization.
Before you begin, you can either use the cat /boot/grub/grub.cfg | grep menuentry command or check the current order of GRUB menu entries when booting.
The menu items are zero-indexed, so the first entry is represented by 0, the second entry is 1, the third is 2, and so on.
- Start by creating a backup of the config file with the following command:
sudo cp /etc/default/grub /etc/default/grub.bak
sudo nano /etc/default/grub
Use EFI Boot Manager
While we only changed the default boot entry with the previous method, the efibootmgr tool allows you to actually change the boot order. As stated, this method won’t for Legacy BIOS systems. But on UEFI systems, you can use the efibootmgr tool as such:
- First, enter efibootmgr and check the current boot order.
Use the -o flag to change the boot order as such:
sudo efibootmgr -o
Change via BIOS/UEFI
In a Windows-Linux dual-boot, if the boot order in the BIOS/UEFI is set to prioritize the Windows Boot Manager, it will run before the GRUB bootloader. As such, GRUB’s boot order would be irrelevant. In such cases, you can access the firmware interface and change the boot order as such:
- When booting, press the BIOS setup key shown on the screen (Function keys or Del).
- On systems with Fast Boot enabled, you might not have enough time to see and press this key. In such cases, you can bring up the GRUB menu first.
With BIOS, press and hold Shift. With UEFI, press Esc a few times when booting. Then, select the Firmware Settings option in the GRUB menu.
Go to the Boot tab and change the boot order here so that the Linux installation is placed higher than the Windows Boot Manager.
Anup Thapa primarily covers Windows systems, networking, and computer hardware at TechNewsToday. Anup has been writing professionally for almost 5 years, and tinkering with PCs for much longer. His love for all things tech started when he got his first PC over 15 years ago. It was a Pentium IV system running Windows XP on a single 256 MB stick. He spent his formative years glued to this PC, troubleshooting any hardware or software problems he encountered by himself. Professionally, Anup has had brief forays into a variety of fields from coding and hardware installation to writing. In doing so, he’s worked with people of different backgrounds and skill levels, from average joes to industry leaders and experts. This has given him not just a versatile skill set, but also a unique perspective for writing that enables him to concisely communicate complex information and solve his reader’s problems efficiently. You can reach out to him at anup@technewstoday.com.
SYNOPSIS
efibootmgr [ -a ] [ -A ] [ -b XXXX ] [ -B ] [ -c ] [ -d DISK ] [ -D ] [ -e 1|3|-1 ] [ -E NUM ] [ —full-dev-path | —file-dev-path ] [ -f ] [ -F ] [ -g ] [ -i NAME ] [ -l NAME ] [ -L LABEL ] [ -m t|f ] [ -M X ] [ -n XXXX ] [ -N ] [ -o XXXX,YYYY,ZZZZ . ] [ -O ] [ -p PART ] [ -q ] [ -r | -y ] [ -t seconds ] [ -T ] [ -u ] [ -v ] [ -V ] [ -w ] [ -@ file ]
DESCRIPTION
efibootmgr is a userspace application used to modify the UEFI Boot Manager. This application can create and destroy boot entries, change the boot order, change the next running boot option, and more.
Details on the UEFI Boot Manager are available from the UEFI Specification, v1.02 or later, available from: http://www.uefi.org
Note: efibootmgr requires that the kernel support access to EFI non-volatile variables through /sys/firmware/efi/vars or /sys/firmware/efi/efivars/.
OPTIONS
The following is a list of options accepted by efibootmgr:
-a | —active Set bootnum active. -A | —inactive Set bootnum inactive. -b | —bootnum XXXX Modify BootXXXX (hex). -B | —delete-bootnum Delete bootnum. -c | —create Create new variable bootnum and add to bootorder. -C | —create-only Create new variable bootnum and and do not add to bootorder. -d | —disk DISK The disk containing the loader (defaults to /dev/sda). -D | —remove-dups Remove duplicated entries from BootOrder. -e | —edd 1|3 Force EDD 1.0 or 3.0 creation variables.
Use -e 1 together with -E if you are using a very old system which uses UEFI to boot, but requires legacy CSM (BIOS) device drivers for storage devices.
-e 3 is now deprecated, and is an alias for —full-dev-path.
-E | —edd-device NUM EDD 1.0 device number (defaults to 0x80). See —edd. —full-dev-path Force creation of boot entries use a full UEFI device path, starting at the PCIe root or equivalent on the current platform. The default is to use a hard disk based HD() abbreviated path.
You shouldn’t need to use this option unless the system firmware won’t boot off of your device using an abbreviated HD() device path.
Note that forcing a full path will fail if we don’t know what the system device root is, how the specified device is connected to it, or how to encode any one of those.
—file-dev-path Force creation of boot entries use an abbreviated UEFI device path which starts with the File() portion of the path. The default is to use a hard disk based HD() abbreviated path. -f | —reconnect Re-connect devices after driver is loaded. Only applicable for driver entries. -F | —do-not-reconnect Do not reconnect devices after driver is loaded. Only applicable for driver entries. -g | —gpt Force disk with invalid PMBR to be treated as GPT. -i | —iface NAME Create a netboot entry for the named interface. -k | —keep NAME Keep old entries when adjusting order. -l | —loader NAME Specify a loader (defaults to \EFI\arch\grub.efi). -L | —label LABEL Boot manager display label (defaults to «Linux»). -m | —mirror-below-4G t|f Set t if you want to mirror memory below 4GB. -M | —mirror-above-4G X X percentage memory to mirror above 4GB. Floating-point value with up to 2 decimal places is accepted. -n | —bootnext XXXX Set BootNext to XXXX (hex). -N | —delete-bootnext Delete BootNext. -o | —bootorder XXXX,YYYY,ZZZZ Explicitly set BootOrder (hex). Any value from 0 to FFFF is accepted so long as it corresponds to an existing Boot#### variable, and zero padding is not required. -O | —delete-bootorder Delete BootOrder. -p | —part PART Partition number containing the bootloader (defaults to 1). -q | —quiet Quiet mode — suppresses output. -r | —driver Operate on Driver#### variables instead of Boot#### variables. -t | —timeout seconds Boot Manager timeout, in seconds. -T | —delete-timeout Delete Timeout variable. -u | —unicode | —UCS-2 Handle extra command line arguments as UCS-2 (default is ASCII). -v | —verbose Verbose mode — prints additional information. -V | —version Just print version string and exit. -w | —write-signature Write unique signature to the MBR if needed. -y | —sysprep Operate on SysPrep#### variables instead of Boot#### variables. -@ | —append-binary-args Append extra variable args from file (use — to read from stdin). Data in file is appended as command line arguments to the boot loader command, with no modification to the data, so you can pass any binary or text data necessary.
EXAMPLES
Displaying the current settings (must be root):
[root@localhost ~]# efibootmgr BootCurrent: 0004 BootNext: 0003 BootOrder: 0004,0000,0001,0002,0003 Timeout: 30 seconds Boot0000* Diskette Drive(device:0) Boot0001* CD-ROM Drive(device:FF) Boot0002* Hard Drive(Device:80)/HD(Part1,Sig00112233) Boot0003* PXE Boot: MAC(00D0B7C15D91) Boot0004* Linux
Each of the above are boot variables, which are defined as follows:
• BootCurrent — the boot entry used to start the currently running system • BootOrder — the boot order as would appear in the boot manager. The boot manager tries to boot the first active entry in this list. If unsuccessful, it tries the next entry, and so on. • BootNext — the boot entry which is scheduled to be run on next boot. This supersedes BootOrder for one boot only, and is deleted by the boot manager after first use. This allows you to change the next boot behavior without changing BootOrder. • Timeout — the time in seconds between when the boot manager appears on the screen until when it automatically chooses the startup value from BootNext or BootOrder. • Five boot entries (0000 — 0004), along with the active/inactive flag (* means active) and the name displayed on the screen.
Creating a new boot option
An OS installer would call efibootmgr -c. This assumes that /dev/sda1 is your EFI System Partition, and is mounted at /boot/efi. This creates a new boot option, called «Linux», and puts it at the top of the boot order list. Options may be passed to modify the default behavior. The default OS Loader is \EFI\arch\grub.efi.
Changing the boot order
Assuming the configuration in the first example, efibootmgr -o 3,4 could be called to specify PXE boot first, then Linux boot.
Changing the boot order for the next boot only
Assuming the configuration in the first example, efibootmgr -n 4 could be called to specify that the Linux entry be taken on next boot.
Deleting a boot option
Assuming the configuration in the first example, efibootmgr -b 4 -B could be called to delete entry 4 and remove it from the BootOrder.
Creating network boot entries
A system administrator wants to create a boot option to network boot. You create the boot entry with: efibootmgr -c -i eth0 -L netboot [ -l ‘\filename.efi’ ]
BUGS
Please direct any bugs, features, patches, etc. to the Red Hat bootloader team at https://github.com/rhboot/efibootmgr .
AUTHOR
This man page was generated by dann frazier for the Debian GNU/Linux operating system and updated by Robert Bisewski , but may be used by others.
It has subsequently been modified by Robbie Harwood for the efibootmgr project.
Package name: core/efibootmgr Version: 18-2 Upstream: https://github.com/rhboot/efibootmgr Licenses: GPL2 Manuals: /listing/core/efibootmgr/ Table of contents
Powered by archmanweb, using mandoc for the conversion of manual pages.
The website is available under the terms of the GPL-3.0 license, except for the contents of the manual pages, which have their own license specified in the corresponding Arch Linux package.