The purpose of this guide is purely informational and as such cPanel, LLC will not assume responsibility for any potential adverse outcomes that might arise from its adoption. You may, therefore, wish to seek assistance from a qualified system administrator in case you require further assistance with upgrading the kernel on your system.
On a CentOS system the
yum package manager allows kernel updates. However, CentOS does not offer the latest kernel versions in the official repository. Many Linux distributions, CentOS included, provide their own "longterm maintenance" kernels that may or may not be based on those maintained by kernel developers (releases are not hosted at kernel.org). In the case of CentOS, the kernel versions are usually at least two versions behind the latest kernel mainline version.
It is easy to tell if you are running a distribution kernel. Unless you have downloaded, compiled, and installed your own version of kernel from kernel.org, you are more than likely running a distribution kernel. To find out the version of your kernel, run uname -r:
# uname -r
5.6.19-300.fc32.x86_64. (This is a distribution kernel)
If you see anything at all after the dash, you are running a distribution kernel.
You can find more information on kernel versions corresponding to different CentOS releases here:
However, despite the fact that each distribution offers its own kernel, that does not mean that you are stuck with whatever kernel version your distribution offers. You still can upgrade your kernel version to the most recent version if you wish to. To update the kernel on CentOS, you’ll need to install a third-party repository called ElRepo. ElRepo offers the latest kernel versions available from kernel.org.
There are two types of Linux kernel versions:
- Stable long-term supported kernel release – updated less frequently, but supported longer.(LT)
- Mainline kernel release – a shorter support term but more frequent updates. (ML)
ElRepo offers both of these releases.
What is ELRepo?
ElRepo is an RPM repository for Enterprise Linux packages. ELRepo supports Red Hat Enterprise Linux (RHEL) and its derivatives (Scientific Linux, CentOS & others).
The ELRepo Project focuses on hardware-related packages to enhance your experience with Enterprise Linux. This includes filesystem drivers, graphics drivers, network drivers, sound drivers, webcam, and video drivers. However, here we are only interested in the kernel packages offered by the ELRepo repository.
How To Enable The ELRepo Repository?
Import the public key:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
Detailed info on the GPG key used by the ELRepo Project can be found on this page:
If you have a system with Secure Boot enabled, please see the SecureBootKey page here:
To install ELRepo repository for RHEL-8 or CentOS-8:
yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
To install ELRepo repository for RHEL-7, SL-7 or CentOS-7:
yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
To make use of ELRepo's mirror system, you might need to install te yum-plugin-fastestmirror via this command:
yum install yum-plugin-fastestmirror
Check Your Current Kernel Version:
To check the current kernel version on CentOS system, open a command-line interface and enter the following command:
The system should return with an entry that appears like this:
Linux 3.10.0-862.el7.x86-64 x86-64
The output indicates which version of the kernel you are currently running, and on which architecture it’s based on. Here we are running version
3.10.0 and the architecture is
Update CentOS Repositories:
Prior to upgrading the kernel, all packages must be updated to the latest version.
To update CentOS software repositories, use the command:
sudo yum -y update
Your software repository is now updated. This ensures you have access to the latest version of the kernel.
To list available kernels in the ELRepo repository, enter:
yum list available --disablerepo='*' --enablerepo=elrepo-kernel
The system should return a list of available kernels. In the list, note the line that says
kernel-lt – signifying a stable long-term support release – or
kernel-ml – which indicates a mainline release, with a shorter support term but with more frequent updates. These are the same two main kernel release versions previously discussed.
Next, look at the right-hand column, and notice a series of letters and numbers (which looks something like ‘4.4.113-1.e17.elrepo’). This is the kernel version. Use these two pieces of information to decide which kernel version you want to install.
yum --disablerepo=\* --enablerepo=elrepo list available
Or alternatively by vising this page:
To install the latest mainline kernel:
sudo yum --enablerepo=elrepo-kernel install kernel-ml
To install the latest long-term support kernel:
sudo yum --enablerepo=elrepo-kernel install kernel-lt
The system should download the software, then prompt you to confirm that it’s OK to install – type
y and press enter. Allow the process to complete.
Reboot and Select the New Kernel:
Reboot your system by running the command:
You’ll be presented with the GRUB, or boot menu.
Use the arrow keys to select the Linux kernel you have just installed, then press
Enter. Your operating system should boot normally but this time into the new kernel.
Set The Default Kernel To The New Version:
Once you confirm that the new kernel is compatible and working correctly, you’ll want to edit the GRUB boot utility so that, by default, it loads your new kernel.
Navigate to /etc/default/ and open the grub file with your text editor. Or, type the following in the terminal:
sudo vim /etc/default/grub
Once the file opens, look for the line that says GRUB_DEFAULT=X, and change it to GRUB_DEFAULT=0 (zero). This line will instruct the boot loader to default to the first kernel on the list, which is the latest.
Save the file, and then type the following command in the terminal to recreate the kernel configuration:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot once more:
Verify that the boot loader is set to load the latest kernel by default.
You have successfully upgraded the kernel for your system.