How to Upgrade Linux Kernel on CentOS 7

upgrade linux kernel centos 7

The Linux kernel is the core or main component of the Linux operating system. The first kernel release was first written in 1991 by Linus Torvalds, who at the time, was a computer science student at the University of Helsinki.  The kernel lies between your computer hardware components and the running applications. In this tutorial, we focus on highlight how you can upgrade Linux kernel on CentOS 7.

But why upgrade the kernel in the first place? Well, upgrading the kernel comes with some immense benefits. These include improved support for third-party drivers such as NVIDIA, security patches, and added functionality. Without much further ado, let's roll our sleeves and demonstrate how to upgrade the kernel on CentOS 7.


For this exercise. ensure that you have the following prerequisites before you get started out.

  1. An instance of CentOS 7  system.
  2. A sudo user for executing elevated privileges.
  3. A stable internet connection.
Before proceeding with upgrading the kernel on your system, please backup all your important data on an external drive as the upgrade might make the system unstable at times.

Step 1) Verify your current kernel version

Before anything else, you need to check your current kernel version. This will enable you to distinguish the kernel versions after the upgrade. To achieve this, execute the uname command:

$ uname -smr
check kernel version in CentOS 7

From the output, we can see the kernel version (3.10)  and the system architecture ( which is 64-bit ).

Step 2) Update CentOS package repositories

Having confirmed the Linux kernel version, the next step will be to update the package repositories. To accomplish this, invoke the command:

$ sudo yum update

When prompted, click 'Y' for yes to proceed with updating the repositories.

update CentOS 7

This usually takes a long time and depending on your internet speed, this could last between 30 minutes to 1 hour. This is also a good time to do some stretching or go do some shopping at your nearest grocery store.

Step 3) Enable the Elrepo repository

Upgrading the kernel requires the installation of a third-party repository known as ElRepo repository. This is a CentOS community repository that provides the latest kernel version that offers the latest hardware packages to enhance the overall user experience. These packages include video drivers,  graphic drivers, network and webcam drivers to mention just but a few.

To enable the repository, head over to your terminal and run the command:

$ sudo rpm --import

This command installs the Elrepo repository GPG key that provides a digital signature to check the authenticity of installed software packages. Usually, CentOS blocks the installation of unsigned software packages.

Once you have enabled the repository, execute the following command to install Elrepo repository:

$ sudo rpm -Uvh
Enable elrepo repository

Step 4) List available kernel versions

Before you upgrade Linux kernel on CentOS 7, it's prudent to first check the available kernel versions. To do so, run the command;

$ yum list available --disablerepo='*' --enablerepo=elrepo-kernel
List avaiable repositories

On the terminal, you should get a list of available kernel modules The kernel-lt indicates a stable LTS ( long term support) release while kernel-ml signifies a mainline release that offers short support term but provides more frequent updates. To the right is a column that shows the kernel versions and we can observe that the latest mainline release is 5.8.9 while the latest long term release is 4.4.236  at the time of writing this guide.

Step 5) Install the latest kernel version

To upgrade the kernel on CentOS 7. you need to install the latest kernel version. To install the newest mainline release, invoke the command:

$ sudo yum --enablerepo=elrepo-kernel install kernel-ml
upgrade Linux kernel on CentOS 7

Press 'Y' for yes to proceed with the installation. At the very end, you should get the output below to indicate that the installation was successful.

upgrade Linux kernel on CentOS

If you want to install the latest long term version, run:

$ sudo yum --enablerepo=elrepo-kernel install kernel-lt
upgrade Linux kernel on CentOS 7

Once again, hit  'Y' for yes to proceed with the installation.

Step 6) Reboot and choose the latest kernel

Upon rebooting, the grub menu will now have the latest kernel entries pointing to the latest kernel versions that we installed earlier in this tutorial. However, the old kernel version remains the preselected one as shown.

grub menu options centos7

Later on,  we shall later modify the grub menu to point to the latest kernel entry. For now, select the latest kernel entry and hit ENTER.

select the latest kernel entry

Once logged in, fire up the terminal and once more, verify the kernel's version.

verify kernel version centos7

Perfect ! this indicates that we are now riding on the latest kernel.

Step 7) Set default kernel version

As we promised in the previous step, we are going to set the default kernel version to the latest version. For this to happen, we are going to modify the /etc/default/grub file. Open the file using your preferred text editor and set the  GRUB_DEFAULT value to zero as shown


Save and exit the configuration file and reconfigure the grub bootloader by running the command:

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

You should get output similar to what we have here.

reconfigure grub

Finally, reboot and be sure that this time, the latest kernel entry will be preselected.


We have reached the end of this article. In this guide, we have walked you through the steps required to upgrade the Linux kernel in CentOS 7. Your feedback is much welcome.

Leave a Comment