(Last Updated On: March 5, 2019)

How can I install Linux Kernel 5.0 on CentOS 7?, Can I upgrade to Kernel 5.0 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.

How to Install Linux Kernel 5.0 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.0 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 https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

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

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

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.0 on CentOS 7.

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

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

$ sudo yum --enablerepo=elrepo-kernel install kernel-ml
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base: mirror.aptus.co.tz
elrepo: elrepo.reloumirrors.net
elrepo-kernel: elrepo.reloumirrors.net
extras: mirror.aptus.co.tz
updates: mirror.aptus.co.tz
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
Installing:
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.0 in the Grub menu to boot to newly installed Kernel 5.0 on CentOS 7.

Confirm booted kernel with uname command.

$ uname -r
5.0.0-1.el7.elrepo.x86_64

Setting Kernel 5.0 on CentOS 7 as default

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

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

Regenerate grub configuration file.

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

Uninstall Kernel 5.0 on CentOS 7

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

Confirm your booted Kernel version.

$ uname -r
3.10.0-957.1.3.el7.x86_64

Then uninstall Linux Kernel 5.0 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
Removing:
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.0 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