How can I install Linux Kernel 5.x on CentOS 7?, Can I upgrade to Kernel 5.x on CentOS 7?. By default, CentOS ships with a custom-built kernel to ensure its integrity and compatibility with supported hardware. A Linux kernel comprises of the base kernel itself and a number of kernel modules. The base kernel is always loaded during boot but modules can be loaded on demand.

Below is a list of Kernel Packages available for CentOS 7:

  • kernel: This package contains the kernel for single-core, multi-core, and multi-processor systems
  • kernel-devel : This contains kernel headers and makefiles used to build kernel modules against installed Kernel version.
  • kernel-headers: This package includes the C header files that powers interfacing between the Linux kernel and user-space libraries and programs.
  • kernel-tools: Contains tools for manipulating the Linux kernel and supporting documentation.
  • perf: This package contains the perf tool, which enables performance monitoring of the Linux kernel.
  • linux-firmware: This contains the firmware files required by various devices to operate.

Install Linux Kernel 5.x on CentOS 7

The latest release of Kernel can be installed on CentOS 7 by building it or using an RPM repository with pre-built packages. In this guide, we will use ELRepo to install Linux Kernel 5.x on CentOS 7.

ELRepo is an RPM repository for Enterprise Linux packages. It supports Red Hat Enterprise Linux (RHEL) and its derivatives such as Scientific Linux, CentOS e.t.c. Add ELRepo repository to your CentOS 7 by running the commands below.

sudo yum -y install

Once the repo has been added, import GPG key used for signing packages.

sudo rpm --import

This will add elrepo-kernel channel which provides both the long-term(kernel-lt) support kernels and latest stable mainline kernels(kernel-ml) for RHEL and CentOS. This channel is not enabled by default and you need to explicitly enable it before installing Kernel 5.x on CentOS 7.

$ sudo yum --disablerepo="*" --enablerepo="elrepo-kernel" list available | grep kernel-ml
kernel-ml.x86_64                        5.4.12-1.el7.elrepo        elrepo-kernel
kernel-ml-devel.x86_64                  5.4.12-1.el7.elrepo        elrepo-kernel
kernel-ml-doc.noarch                    5.4.12-1.el7.elrepo        elrepo-kernel
kernel-ml-headers.x86_64                5.4.12-1.el7.elrepo        elrepo-kernel
kernel-ml-tools.x86_64                  5.4.12-1.el7.elrepo        elrepo-kernel
kernel-ml-tools-libs.x86_64             5.4.12-1.el7.elrepo        elrepo-kernel
kernel-ml-tools-libs-devel.x86_64       5.4.12-1.el7.elrepo        elrepo-kernel

Now that we have confirmed availability of Linux Kernel 5.x, we can proceed to install it.

$ sudo yum --enablerepo=elrepo-kernel install kernel-ml
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
elrepo | 2.9 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/5): base/7/x86_64/group_gz | 166 kB 00:00:00
(2/5): extras/7/x86_64/primary_db | 180 kB 00:00:00
(3/5): elrepo/primary_db | 270 kB 00:00:02
(4/5): updates/7/x86_64/primary_db | 2.4 MB 00:00:03
(5/5): base/7/x86_64/primary_db | 6.0 MB 00:00:06
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:5.0.0-1.el7.elrepo will be installed
--> Finished Dependency Resolution
Dependencies Resolved
Package Arch Version Repository Size
kernel-ml x86_64 5.0.0-1.el7.elrepo elrepo-kernel 47 M
Transaction Summary
Install 1 Package
Total download size: 47 M
Installed size: 215 M
Is this ok [y/d/N]: y

Also install kernel-ml-devel,kernel-ml-headers,kernel-ml-tools,perf:

sudo yum -y --enablerepo=elrepo-kernel install kernel-ml-{devel,headers,perf}

Reboot the system:

sudo reboot

Select Kernel 5.x in the Grub menu to boot to newly installed Kernel 5.x on CentOS 7.

install kernel 5.0 centos 7

Confirm booted kernel with uname command.

$ uname -r

Setting Kernel 5.x on CentOS 7 as default

Edit the file /etc/default/grub and set GRUB_DEFAULT=0.

GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_CMDLINE_LINUX="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop crashkernel=auto"

Regenerate grub configuration file.

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

Uninstall Kernel 5.x on CentOS 7

You now have Linux Kernel 5.x installed on CentOS 7. To uninstall, boot to older Kernel

uninstall kernel 5.0 centos 7

Confirm your booted Kernel version.

$ uname -r

Then uninstall Linux Kernel 5.x on CentOS 7.

$ sudo yum remove kernel-ml kernel-ml-{devel,headers,perf}
Loaded plugins: fastestmirror
No Match for argument: kernel-ml-perf
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:5.0.0-1.el7.elrepo will be erased
---> Package kernel-ml-devel.x86_64 0:5.0.0-1.el7.elrepo will be erased
---> Package kernel-ml-headers.x86_64 0:5.0.0-1.el7.elrepo will be erased
--> Finished Dependency Resolution
Dependencies Resolved
Package Arch Version Repository Size
kernel-ml x86_64 5.0.0-1.el7.elrepo @elrepo-kernel 215 M
kernel-ml-devel x86_64 5.0.0-1.el7.elrepo @elrepo-kernel 47 M
kernel-ml-headers x86_64 5.0.0-1.el7.elrepo @elrepo-kernel 4.6 M
Transaction Summary
Remove 3 Packages
Installed size: 266 M
Is this ok [y/N]: y

For Ubuntu and Linux Mint system, check:

How to Install Linux Kernel 5.x on Ubuntu / Linux Mint

Other interesting readings:

Ten Best Terminal Emulators for Linux

Red Hat Enterprise Linux 8 (RHEL 8) New Features & Review

How to Optimize Linux System with Stacer

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here