Set “older” kernel as default grub entry

1

Question: I have several kernel images installed on my CentOS box, and I want to change the default boot kernel either permanently or temporarily ("just once"). How can I change the default kernel version used by GRUB/GRUB2 on CentOS?

When there are multiple kernels installed on CentOS, GRUB/GRUB2 boot loader chooses and loads one of them as the default kernel during boot time. The default kernel can be chosen differently. For example, CentOS can be configured to boot into a newly installed kernel (e.g., CentOS 6), or it can boot a last saved entry regardless of the kernel is newer or older (e.g., CentOS 7).

If you want to change the default kernel to a particular kernel version permanently, you can modify GRUB configuration as follows.

Change the Default Kernel Version Permanently on CentOS 7

First, list all available kernel images added to GRUB2 by running the following command.

$ grep '^menuentry' /boot/grub2/grub.cfg

Identify...

0 0
2

by

Mookey

Last Updated January 10, 2018 22:02 PM

Can you guys please help me use Grub Customizer to set an older version of the kernel 4.4.0 of Ubuntu 16.04 LTS as default when booting? I'm not using a dual boot system, and I have installed 4.4.8 kernel to help me solve the suspend problem, but it's draining my battery.

What do I have to do, I wouldn't want to f*** things up.

Answers 3

Im not familiar with that program but if I want my computer to boot to a different kernel I just manually edit the grub file located at:

/etc/default/grub

Look for

GRUB_DEFAULT=0 (or whatever your default is set too)

Change that line to the kernel you want loaded ... looking at your list there it looks like 0 would be the standard 4.4.8 and 3 would be the standard 4.4.0

Once you have selected the one you want save the file (you will have to edit the file in root) and then use the command:

sudo update-grub

now when you reboot...

0 0
3

GRUB2 is the most common bootloader for RHEL 7 systems. A symlink to the GRUB2 config file should be present at /etc/grub2.cfg. The post describes changing the default kernel to a old kernel.

How GRUB2 selects which kernel to boot from

By default, the value for the directive GRUB_DEFAULT in the /etc/default/grub file is “saved”.

# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet" GRUB_DISABLE_RECOVERY="true"

This instructs GRUB 2 to load the kernel specified by the saved_entry directive in the GRUB 2 environment file, located at /boot/grub2/grubenv.

# cat /boot/grub2/grubenv # GRUB Environment Block saved_entry=Red Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo)

One can set another GRUB record to be the default, using the grub2-set-default command, which will update...

0 0
4

You can use > character and numbers to select a submenu entry as default.

0 refers to first menu entry in grub. If parent of subentries starts from index 1 and you want to boot from third submenu entry as default (so that index number is 2), you need to change GRUB_DEFAULT variable as below:

GRUB_DEFAULT="1>2"

Please note that, there are no space characters before or after >

But, it is hard to describe submenu entry selection with numbers. There is another way, you can also use menu names like below:

GRUB_DEFAULT="Advanced options for Debian GNU/Linux>Debian GNU/Linux, with Linux 3.18.25.jessiemptcp"

After that, you need to run sudo update-grub command as...

0 0
5
...
0 0
6

With newer systems like CentOS 7 and Ubuntu 14.04 and 16.04 using Grub2, you can no longer simply update a single file to have your kernel boot off an older or newer kernel. There are a series of steps that must be followed. The examples below will show how to boot off an older kernel for their respective operating systems.

Please note, the instructions in this article will lock your kernel on whichever one you selected. Even if your system receives automatic kernel updates, those new kernels will have to be manually enabled within grub if you want to use them.

CentOS 7

First, check to see which kernel is currently running:

[[email protected] ~]# uname -r 3.10.0-514.16.1.el7.x86_64

That shows us we’re running 3.10.0-514.16.1, however I need to be running 3.10.0-327.36.3. So to use this specific named kernel, first changed the GRUB_DEFAULT to ‘saved’ in /etc/default/grub by:

[[email protected]~]# cp /etc/default/grub /etc/default/grub.bak [[email...
0 0
7

How can I pick which kernel GRUB2 should load by default? I recently installed a the linux realtime kernel and now it loads by default. I'd like to load the regular one by default.

So far I only managed to pick the default OS.. and for some reason the /boot/grub.cfg already assumes that I want to load the rt-kernel and put it into the generic linux menu entry (in my case Arch Linux).

As mentioned in the comments, you can set the default kernel to boot into using the grub-set-default X command, where X is the number of the kernel you want to boot into. In some distributions you can also set this number by editing the /etc/default/grub file and setting GRUB_DEFAULT=X, and then running update-grub.

The number is the index to an array of kernels/kernel settings shown in the GRUB menu during boot, with 0 being the first (top-most) entry. You can usually find the right number by looking for menuentry lines in /boot/grub/grub.cfg, like so:

grep menuentry...
0 0
8

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 the text editor of your choice (ie. gedit, etc.).

sudo gedit /etc/default/grub

Find the line that contains GRUB_DEFAULT=0 - this is what you'll want to edit to set the default. To know what to change it to, you must know where it is on the list (1st, 2nd, 3rd, etc.). For example, on my computer, I have:

The Latest KernelThe Latest Kernel (Recovery mode)Previous Linux VersionsMemory test (memtest86+)Memory test (memtest86+, serial console 115200)

If you choose the "Previous Linux Versions", you will see:

Old KernelOld Kernel (Recovery mode)Older KernelEtc.

Essentially, all the older kernels that are still installed. These are sub-choices, of a sort. So in my case, since "Previous Linux Versions" is 3rd on the boot list, the first kernel inside of it would be...

0 0
9

This page documents common problems with the Linux kernel in Fedora.

How to set kernel boot options

Kernel boot options are contained in the file /boot/grub/grub.conf. Each installed kernel has a group of lines called a stanza describing:

the title of the operative system to load where to find the boot partition (in grub named root!) what kernel (vmlinuz-*) to boot, with additional kernel options the name of the initrd to load

A typical stanza looks something like this:

title Fedora 13 (2.6.33.5-124.fc13.i686.PAE) root (hd1,7) kernel /vmlinuz-2.6.33.5-124.fc13.i686.PAE ro root=/dev/mapper/VG_f13-LV_f13_root rd_LVM_LV=VG_f13/LV_f13_root rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rhgb quiet initrd /initramfs-2.6.33.5-124.fc13.i686.PAE.img title CentOS 5 (2.6.18-194.3.1.el5) root (hd0,4) kernel /vmlinuz-2.6.18-194.3.1.el5 ro root=/dev/mapper/VG_CentOS-LV_CentOS_root ...
0 0
10
Managing EFI Boot Loaders for Linux: Using GRUB 2

Originally written: 9/23/2011; last update: 7/16/2017

This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!

This page is part of my Managing EFI Boot Loaders for Linux document. If a Web search has brought you to this page, you may want to start at the beginning.

The GRand Unified Bootloader (GRUB) is actually two boot loaders. This page describes GRUB 2, which is the current version of the boot loader. The previous page, Using GRUB Legacy, describes the previous (and now discontinued) version of the boot loader.

When to Use GRUB 2

GRUB 2 is the default EFI-mode boot loader for many distributions, including current releases of Ubuntu Linux, OpenSUSE, and Fedora. Therefore, GRUB 2 is...

0 0