Upgrading your kernel version in CentOS

One of my favorite tools for upgrading a Linux kernel is grubby. It presents you with a clean view all the kernel versions on your system. Before you start using grubby, you will need to install the new kernel version.

First, import the public keys and then install elrepo repository.

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

After you have install elrepo and imported the public keys, you will need to list all the packages in the rum elrepo repositories.

yum list available --disablerepo='*' --enablerepo=elrepo-kernel

For long term support kenerls you will need to look for  “kernel-lt” and for mainline kernel, you will need to look for “kernel-ml”. Ill be using mainline stable kernel.

yum --disablerepo='*' --enablerepo=elrepo-kernel install kernel-ml

This will download the latest kernel version onto your system. To utilize the new kernel version on your system, use grubby to change the default kernel version on your system. (See Below)

Listing the default kernel:

grubby --default-kernel
/boot/vmlinuz-4.14.12-1.el7.elrepo.x86_64

To find out what the index number of the default enter the following

grubby --default-index
0

To view all the kernels enter the following command:

grubby --info=ALL

grubby --info=ALL
index=0
kernel=/boot/vmlinuz-4.14.12-1.el7.elrepo.x86_64
args="ro crashkernel=auto rd.lvm.lv=cl/root rhgb quiet LANG=en_US.UTF-8"
root=/dev/mapper/cl-root
initrd=/boot/initramfs-4.14.12-1.el7.elrepo.x86_64.img
title=CentOS Linux (4.14.12-1.el7.elrepo.x86_64) 7 (Core)
index=1
kernel=/boot/vmlinuz-3.10.0-693.11.6.el7.x86_64
args="ro crashkernel=auto rd.lvm.lv=cl/root rhgb quiet LANG=en_US.UTF-8"
root=/dev/mapper/cl-root
initrd=/boot/initramfs-3.10.0-693.11.6.el7.x86_64.img
title=CentOS Linux (3.10.0-693.11.6.el7.x86_64) 7 (Core)
index=2
kernel=/boot/vmlinuz-3.10.0-693.11.1.el7.x86_64
args="ro crashkernel=auto rd.lvm.lv=cl/root rhgb quiet LANG=en_US.UTF-8"
root=/dev/mapper/cl-root
initrd=/boot/initramfs-3.10.0-693.11.1.el7.x86_64.img
title=CentOS Linux (3.10.0-693.11.1.el7.x86_64) 7 (Core)
index=3
kernel=/boot/vmlinuz-3.10.0-514.el7.x86_64
args="ro crashkernel=auto rd.lvm.lv=cl/root rhgb quiet LANG=en_US.UTF-8"
root=/dev/mapper/cl-root
initrd=/boot/initramfs-3.10.0-514.el7.x86_64.img
title=CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)
index=4
kernel=/boot/vmlinuz-0-rescue-51ec8c545ba045e2a0f287692cba31a3
args="ro crashkernel=auto rd.lvm.lv=cl/root rhgb quiet"
root=/dev/mapper/cl-root
initrd=/boot/initramfs-0-rescue-51ec8c545ba045e2a0f287692cba31a3.img
title=CentOS Linux (0-rescue-51ec8c545ba045e2a0f287692cba31a3) 7 (Core)
index=5
non linux entry

If you want to change the default kernel on your system, enter this:

grubby --set-default /boot/<kernel-version-goes-here>

Example:

 grubby --set-default /boot/vmlinuz-4.14.12-1.el7.elrepo.x86_64

After you have set the default kernel, reboot your system. Make sure to monitor it for any issues.  To verify that you are running the latest kernel version type in the following command

uname -sr

your output should look like this

Linux 4.14.12-1.el7.elrepo.x86_64

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s