How to Update the Kernel in CentOS

How to Update the Kernel in CentOS

Your Linux kernel is the center of the operating system. Its importance is such, that you will hardly ever get the chance, or need to interact with it directly. It does most of its work behind the scenes, and coordinates everything from multitasking, to memory management.

Sometimes, you might have the need to upgrade your kernel version, or install a new one. Different distributions don’t use the Linux kernel “as is”. They make changes and updates to more accurately reflect their needs. Sometimes, you want a new kernel to have improved security patches, more stability, and access to the latest drivers. This tutorial will show you how to upgrade the kernel in CentOS.

Getting the Existing Kernel Version

You can get all kinds of system info, using the “uname” command. For our purposes, we get the kernel version by typing in the following command:

uname -rs

You can also get the Linux version number for CentOS using:

cat /etc/centos-release

This will produce an output similar to the one below:

You can get even more information using:

cat /proc/version

All of these will give you information about your distribution version and kernel version. Now let’s look at how to change your kernel.

Getting the Repos for the New Kernel

The base CentOS repos don’t automatically provide you with the ability to upgrade to a new kernel. Neither do the standard EPEL repositories. Instead, the repo that we’re looking for is called “ELRepo”. So first we need to install the repository, then list the various kernels available before installation.

As mentioned on the ELRepo page, you can get the repo by first importing the GPG key and then downloading and installing the RPM. Or you can simply use “yum install” to directly install the rpm package you want. For example, on CentOS 7:

yum install

And on CentOS 6:

yum install

This will install the ELRepo repository on your system, and give you access to all the good stuff like kernels, extra packages, and testing bundles.

Getting the List of Kernels and Updating

The ELRepo repository is disabled by default, and for good reason. It contains packages and updates that can potentially wreck your system if you’re not careful! So if we want to install stuff from ELRepo, we have to either enable it manually, or temporarily. I prefer to do the latter, since I don’t want this repository to be consulted each and every time I use my package manager. I risk accidentally changing or updating a package that might break my system!

The kernels in ELRepo are in a “sub repo” called “elrepo-kernel”. So first, let’s list everything available in there while disabling all the other repos in the system temporarily. We do that using this command:

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

As you can see, we first disable everything, and then enable the specific repo we want. Here’s the output:

This is a complete list of kernels available with ELRepo. The suffix “lt” stands for “Long Term”, and “ml” stands for “Main Line”. As of now, long term kernels have been configured to work with CentOS/RHEL 5 & 6. Mainline kernels have been compiled with version 6 and 7 in mind. To install the “lt” kernel as highlighted above, simply install it like any other kernel with your package manager:

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

As you can see below, it asks you for confirmation:

Install a Different Kernel in CentOS

Type “y” and proceed with the installation. Along the way, it’ll ask you for permission to import the GPG key:

Once again, say yes and the kernel will install after downloading from the repo. That’s it! Now you just need to reboot your system for the changes to take effect and you’ve successfully updated the kernel on your CentOS system!

Leave a Reply

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

Disclosure: We receive a compensation from some of the companies whose products are presented on our website.