How to Update CentOS 7/8 Kernel

Este post também está disponível em: Português (Portuguese (Brazil))

How to Update CentOS 7 or 8 Kernel

A quick introduction, after all, what is the Kernel?

The Kernel is the fundamental layer of the operating system. It works at the most basic level and is responsible for managing resources, ram, CPU etc…

Kernel starts when server or PC starts and recognizes components, GPU, memory, peripherals. In other words the Kernel is the heart of Linux.

Okay, now for the steps to securely update the CentOS 7 or 8 Kernel.

As a source for our update, we will use the ELRepo repository which is a community repository for Enterprise Linux distributions (Red Hat Enterprise Linux (RHEL), CentOS, Scientific Linux).

ELRepo focuses on hardware-related packages including file system drivers, graphics drivers, network drivers, sound card drivers, webcam, and many others.

1 – Update, upgrade with Yum your CentOS and a reboot at the end:

yum update -y; yum upgrade -y; reboot;

2 – Checking the Kernel version installed on the server

uname -snr
CentOS 7 default is Kernel 3.xx

3 – Install the yum plugin which will allow a faster update

yum -y install yum-plugin-fastestmirror

4 – Check your CentOS version

cat /etc/os-release

5 – Add the gpg key from the ELRepo repository to the server.

rpm --import

6 – According to your CentOS version, choose the option below:

For CentOS 7:

yum install

For CentOS 8:

yum install

7 – Enable the repository and install the new Kernel

yum --enablerepo=elrepo-kernel install kernel-ml

At this point we have already installed the new Kernel, now let’s configure Grub2 to start with the new Kernel

8 – Use the following command to list the Kernel options

awk -F' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
See option 0 that we have Kernel 5.10.3.xx installed.

9 – Tell Grub the Kernel version you want to use

grub2-set-default 0

9 – Generate the grub2 config with the command ‘grub2-mkconfig’ and then a reboot in CentOS Linux to apply the new kernel.

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

10 – After the reboot check the installed Kernel version

uname -snr
Kernel Version

After installing the new Kernel version, it is possible to optimize the performance and security of the server using sysctl which will act directly on the Kernel. Request HelpSysAdmin services for Kernel optimization and various other services of your server.