I installed a mainline kernel for testing purposes. I would like to set grub to boot from the older kernel by default.
I know I can set the GRUB_DEFAULT=0
setting for the first page of grub but how do I set it to boot by default from one kernel in the second page (Advanced page)?
I would prefer doing this without installing other software (ex. grub-customizer).
Related Questions:
How do I set Windows to boot as the default in the boot loader?
How do I change the grub boot order?
First, make a backup copy of
/etc/default/grub
. If something goes wrong, you can easily revert to the known-good copy.Then edit the file using the text editor of your choice (e.g. gedit, etc.).
Find the line that contains
GRUB_DEFAULT
- this is what you'll want to edit to set the default. You must know the full name of the kernel you want - e.g.Ubuntu, with Linux 3.13.0-53-generic
- along with the full name of the "advanced menu" - e.g.Advanced options for Ubuntu
.You then combine those two strings with
>
and setGRUB_DEFAULT
to them as:GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-53-generic"
(including quotes).Save it, then build the updated grub menu.
See also: GNU GRUB Manual 2.02 or more specifically section 15.1.0 on setting the default.
Note: There is a method utilizing numbers to access kernels and menus but this is not recommended as it is unreliable when kernel updates occur.
The best solution for me was to set (in
/etc/default/grub
):With this settings the last selected value is kept for the next boot. If you have a new kernel you don't have to edit your config.
Don't forget to re-run
sudo update-grub
The solution is from reading:
info grub-mkconfig
Now that an
Advanced
menu is default in Ubuntu, you'll need to select it before the kernel you want using the>
character.Set e.g.:
in
/etc/default/grub
and re-runsudo update-grub
.It is important to note that for the GRUB menu entries numbering starts with
0
. Therefore the1
above points to theAdvanced
menu. As a precaution, you may want to initially setGRUB_TIMEOUT=5
. Some may be unable to access GRUB by hitting a key at boot time. This is a safety net in case you accidentally point to something likeMemory test
instead. It is also necessary to include the above numbers in quotes. It will not work otherwise.I tested on 16.04 LTS.
To be able to set which boot option to use as default you need to know what there is... so:
To display the menu entries without actually booting, try something like:
In order to do it with a GUI, I use Grub Customizer (I'm in Mint but that doesn't count here).
The simplest and most direct way (thanks @eMKi for the suggestion in comment) — best suited for a permanent setting, in General Settings > default entry > predifined, simply select the desired kernel in the drop-down list.
Or, in case one needs the "previous booted entry" to be the one selected (might be useful in dual boot with Windows when doing an Windows update that requires restart, for example) — keeping the Advanced options in the grub list in case the default list is changed within Grub Customizer:
under General settings select the default entry: previous booted entry.
Then, reboot, and during boot select the "Advanced options" entry in the grub list:
and select the older kernel
On the next reboot, the "Advanced options" item will be the one selected by default in the grub list and the last selected kernel from under there will be booted (without opening the full list of kernels).
In case Windows is used, or other option in the grub list, remember to re-do the previous procedure.
In order to change the default kernel to load you can set kernel boot priority in
/etc/default/grub
file.First Take a backup of
/etc/default/grub
before making any changes.While booting if you don't see Grub boot loader at all, you have to make it visible, for that change these 2 lines in Grub as
Now while loading you should be able to see the grub menu.
To change the kernel loading priority you have to make a change in
GRUB_DEFAULT
as the default setting it is set ascheck the serial number of the kernel that you want to set as default, the numbering is 0 indexed, change the index accordingly. eg if you want to load the 6th entry from the top, you have to set the index as 5.
Now update grub using
sudo update-grub
and restart.Check this YouTube video to make grub visible.
Check this Ubuntu help page to know about
GRUB_DEFAULT
.