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