Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Steps to change default kernel version in RHEL/CentOS 8

by | Sep 11, 2021

Want to know steps to change default kernel version in RHEL/CentOS 8? We can help you.

As part of our Server Management Services, we assist our customers with several DirectAdmin queries.

Today, let us discuss the steps followed by our Support techs to change kernel version.

 

Steps to change default kernel version in RHEL/CentOS 8

We have a special designated tool called grubby to change default kernel versions.

Today, let us see the steps followed by our Support Techs to perform the task.

  • Basically, grubby is a command line tool use to configure bootloader menu entries across multiple architectures.
  • Next, it is use for updating and displaying information about the configuration files for various architecture specific bootloaders.
  • Next, it is primarily design to used from scripts which install new kernels and need to find information about the current boot environment
  • Then, if no bootloader configuration file is found, grubby will use the default value for that architecture.

 

List installed kernel versions

rpm -qa | grep kernel | sort
kernel-4.18.0-193.1.2.el8_2.x86_64
kernel-4.18.0-193.14.3.el8_2.x86_64
kernel-4.18.0-193.el8.x86_64
kernel-core-4.18.0-193.1.2.el8_2.x86_64
kernel-core-4.18.0-193.14.3.el8_2.x86_64
kernel-core-4.18.0-193.el8.x86_64
kernel-modules-4.18.0-193.1.2.el8_2.x86_64
kernel-modules-4.18.0-193.14.3.el8_2.x86_64
kernel-modules-4.18.0-193.el8.x86_64
kernel-tools-4.18.0-193.el8.x86_64
kernel-tools-libs-4.18.0-193.el8.x86_64

With RHEL/CentOS 8 now the kernel rpm is distributed across kernel-core and kernel-modules.

Here we got a long list of kernel and it’s dependent packages.

Basically, you can use grubby to get a cleaner output for list of installed kernels

grubby --info=ALL | grep ^kernel
kernel="/boot/vmlinuz-4.18.0-193.14.3.el8_2.x86_64"
kernel="/boot/vmlinuz-4.18.0-193.1.2.el8_2.x86_64"
kernel="/boot/vmlinuz-4.18.0-193.el8.x86_64"
kernel="/boot/vmlinuz-0-rescue-d88fa2c7ff574ae782ec8c4288de4e85"

This will print the initramfs version of all the installed kernels.

Currently active (loaded) kernel

In order to check the currently active kernel version we will use uname with -r which will give us kernel release information:

uname -r
4.18.0-193.el8.x86_64

 

Get more information of boot entries

Now with grubby we have listed the available boot entries, to get more information on individual boot entries we can use:

grubby --info="/boot/vmlinuz-4.18.0-193.14.3.el8_2.x86_64"
index=0
kernel="/boot/vmlinuz-4.18.0-193.14.3.el8_2.x86_64"
args="ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet biosdevname=0 net.ifnames=0 enforcing=0 $tuned_params"
root="/dev/mapper/rhel-root"
initrd="/boot/initramfs-4.18.0-193.14.3.el8_2.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (4.18.0-193.14.3.el8_2.x86_64) 8.2 (Ootpa)"
id="d88fa2c7ff574ae782ec8c4288de4e85-4.18.0-193.14.3.el8_2.x86_64"

 

Check the kernel version which is going to be activated post reboot

To determine the kernel version which will activated post reboot we use:

grubby --grub2 --default-title
Red Hat Enterprise Linux (4.18.0-193.14.3.el8_2.x86_64) 8.2 (Ootpa)

So the currently active kernel was 4.18.0-193.el8.x86_64, but after reboot 4.18.0-193.14.3.el8_2.x86_64 will be active.

 

To list the boot entry of the default kernel i.e. the kernel which will be active post reboot

grubby --default-kernel
/boot/vmlinuz-4.18.0-193.14.3.el8_2.x86_64

Similarly to get the index value of default kernel

grubby --default-index
0

So the boot entry with index value 0 will be activated post reboot of my Linux server.

Change the default kernel (switch kernel version)

Now assuming we wish to change the default kernel which will be active post reboot from 4.18.0-193.14.3.el8_2.x86_64 to 4.18.0-193.1.2.el8_2.x86_64

We can either use:

Firstly, kernel title
Then, kernel boot entry
kernel index value

to change the default kernel version and to switch the kernel for activation post reboot. In this example we are using kernel boot entry to change default kernel version

grubby --set-default "/boot/vmlinuz-4.18.0-193.1.2.el8_2.x86_64"
The default is /boot/loader/entries/d88fa2c7ff574ae782ec8c4288de4e85-4.18.0-193.1.2.el8_2.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.18.0-193.1.2.el8_2.x86_64

So the default kernel version is successfully updated.

 

Verify the new default kernel

Next use the same command as used earlier with grubby to verify the new default kernel:

grubby --default-kernel
/boot/vmlinuz-4.18.0-193.1.2.el8_2.x86_64

To get more information of this boot entry:

grubby --info /boot/vmlinuz-4.18.0-193.1.2.el8_2.x86_64
index=1
kernel="/boot/vmlinuz-4.18.0-193.1.2.el8_2.x86_64"
args="ro resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet biosdevname=0 net.ifnames=0 enforcing=0 $tuned_params"
root="/dev/mapper/rhel-root"
initrd="/boot/initramfs-4.18.0-193.1.2.el8_2.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (4.18.0-193.1.2.el8_2.x86_64) 8.2 (Ootpa)"
id="d88fa2c7ff574ae782ec8c4288de4e85-4.18.0-193.1.2.el8_2.x86_64"

So we can also verify the default index, it should be “1” based on the above information:

grubby --default-index
1

Now reboot the server and verify the active kernel using uname:

uname -r
4.18.0-193.1.2.el8_2.x86_64

So our active kernel is same as we had set for default kernel.

[Need help with either of the above? Feel free to contact us anytime]

 

Conclusion

Today, we discussed about steps to change default kernel version in RHEL/CentOS 8 and how our Support Techs perform it.

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF