How do I change the GRUB boot order?

Solution 1:

You can use an easy-to-use the GUI application called Grub Customizer to make your life a little bit easier. As the name suggests, you can do much more than just reordering GRUB menu entries with it. You can install it from a PPA in 18.04 and older releases, and from the official repositories in 20.04 and newer.

In 18.04 and older releases, add this PPA (you can skip this command on 20.04 and newer):

sudo add-apt-repository ppa:danielrichter2007/grub-customizer

And then run:

sudo apt-get update
sudo apt-get install grub-customizer

(See also this Ask Ubuntu question: https://askubuntu.com/questions/35629.)

There is an How-To Geek article about it, How to Configure the Linux GRUB 2 Boot Menu the Easy Way. Take a look at it if you're interested. Also, there is a solved thread on the Ubuntu Forums, Change boot order in GRUB 2 that mentions this tool.

Here are some screenshots:

screen_1

screen_2

screen_3


Some troubleshooting:

The Grub Customizer settings may work only from within the latest Linux/Ubuntu installation, the one that installed the Grub.

For example, if somebody has two OS-es installed (Windows and Ubuntu), and then installs a third OS (Manjaro, etc) and then tries to follow the above answer, Grub Customizer changes will not work when made from the second OS (Ubuntu, in the example). The program has to be installed in the thirs OS, as it seems that Grub Customizer can only edit the Grub files created by the installation of the system on which itself is installed.

The files that determine the Grub boot menu come in most cases with the latest system installed on a machine, so Grub Customizer has to be installed and used from that Linux system.

Solution 2:

You can also change the grub default boot entry from the command line without having to install any additional tool. This won't change the order in the list but it will allow a different OS to boot by default, which sounds like what you may want anyway.

First, make a backup copy of /etc/default/grub. In case something goes wrong, you can easily revert to the known-good copy:

sudo cp /etc/default/grub /etc/default/grub.bak

Then edit the file using vim or the text editor of your choice:

sudo vim /etc/default/grub

Find the line that contains

GRUB_DEFAULT=0

and set it to

GRUB_DEFAULT=x

where x is the index of grub menu item to which you would like to boot to by default. Note that the menu items are zero-indexed. That means that the first item in the list is 0 and that the sixth item is actually 5. So to boot to the sixth item in the list, the line would read:

GRUB_DEFAULT=5

If you forgot the order of the items, take a look at /boot/grub/grub.cfg. Each menu entry is specified by a line of type:

menuentry 'Ubuntu' [options] {

You can also chose the default by the name instead of index, e.g.:

GRUB_DEFAULT='Ubuntu'

if there was a menuentry 'Ubuntu' line on /boot/grub/grub.cfg. This may be a better method, as it does not depend on the order of the entries, which could change.

To use a kernel in the "Previous Linux Versions" sub-menu use:

GRUB_DEFAULT="Advanced options for Ubuntu>x"

(make sure to include the quotations), where x is the index of the old kernel on the sub-menu, or the name of the kernel as it appears in /boot/grub/grub.cfg. For example,

GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-45-generic"

Then build the updated grub menu:

sudo update-grub

Solution 3:

From the tombuntu site (article by Tom):

GRUB can be configured using the /etc/default/grub file. Before you make any changes to it, it may be a good idea to back it up by creating a copy:

sudo cp /etc/default/grub /etc/default/grub.bak

You can restore the copying the backup over the original:

sudo cp /etc/default/grub.bak /etc/default/grub

Open the file using the text editor with root privileges:

gksu gedit /etc/default/grub

The line GRUB_DEFAULT=0 means that GRUB will select the first menu item to boot. Change this to GRUB_DEFAULT=saved. This change will make it easier to change the default item later.

Save and close the file. Run this command to apply your changes to GRUB’s configuration:

sudo update-grub

The configuration change we made allows the grub-set-default and grub-reboot commands to be used at any time. These allow you to change the default boot item permanently or only for the next boot, respectively.

Run grub-set-default or grub-reboot (with sudo) with the number of the menu item to boot (the first item is 0). This command will change the default to the second item:

sudo grub-set-default 1