Upgrading Linux Kernel in CentOS

PowerADM.com / Linux / CentOS / Upgrading Linux Kernel in CentOS

Let’s look at how to update the Linux kernel to the latest version in CentOS as an example.

Check which version of Linux you have installed:

$ cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)

Check the kernel version:

$ uname -r

The kernel version 4.18 is quite old and we will update it to 5.17.

Let’s start by connecting the ElRepo repository. This is a community repository for Enterprise Linux which provides support for RHEL, CentOS, Scientific, and Fedora.

Import the repository key:

$ rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

And install ElRepo:

$ dnf install -y https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm

List available Linux kernels:

$ dnf --disablerepo="*" --enablerepo="elrepo-kernel" list available| grep kernel-ml

To install the latest available kernel, use the command:

$ dnf --enablerepo=elrepo-kernel install kernel-ml

upgrade kernel in linux with elrepo-kernel install kernel-ml

Now you need to configure Linux to boot with the new kernel:

$ grub2-set-default 0

Update the grub config:

$ grub2-mkconfig -o /boot/grub2/grub.cfg

Restart your host:


Check the kernel version and make sure it has changed to 5.17:

$ uname -r

Two versions of the kernel are currently available on the system:

$ rpm -qa | grep kernel

You can remove the old kernel (optional):

$ dnf remove kernel-core-4.18.0 kernel-devel-4.18.0 kernel-tools-libs-4.18.0 kernel-headers-4.18.0

Check that the old kernel version has been removed:

$ rpm -qa | grep kernel
Leave a Reply

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