How To Upgrade Linux Kernel on Centos 7

In this guide, we want to teach you How To Upgrade Linux Kernel on Centos 7.

Linux kernel is a free, open-source, monolithic, modular, Unix-like operating system kernel. It is the main component of the Linux operating system (OS) and is the core interface between the computer’s hardware and its processes.

The Linux kernel is used by Linux distributions alongside GNU tools and libraries. This combination is sometimes referred to as GNU/Linux. 

Steps To Upgrade Linux Kernel on Centos 7

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Centos 7.

Check the Current Linux Kernel Version

The first step is to check the version of your kernel. To do this, you can use the following command:

uname -msr

In your output you will see:

Output
Linux 3.10.0-1160.42.2.el7.x86_64 x86_64

Then, use the following command to update your Centos repository:

sudo yum -y update

Add ELRepo Repository on Centos 7

To update the kernel on CentOS, you’ll need to install a third-party repository called ElRepo. ElRepo offers the latest kernel version available from kernel.org.

First, import the ElRepo GPG key with the following command:

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

Then, run the command below to add and install the ElRepo on Centos 7:

sudo rpm -Uvh https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

When you are finished, you will get the following output:

Output
Retrieving https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:elrepo-release-7.0-6.el7.elrepo  ################################# [100%]

List Available Kernels on Centos 7

At this point, you can check for the available kernels on your server. To do this, run the command below:

yum list available --disablerepo='*' --enablerepo=elrepo-kernel

In your output you will see:

Output
elrepo-kernel                                            | 3.0 kB     00:00
elrepo-kernel/primary_db                                   | 2.1 MB   00:00
Available Packages
kernel-lt.x86_64                        5.4.217-1.el7.elrepo       elrepo-kernel
kernel-lt-devel.x86_64                  5.4.217-1.el7.elrepo       elrepo-kernel
kernel-lt-doc.noarch                    5.4.217-1.el7.elrepo       elrepo-kernel
kernel-lt-headers.x86_64                5.4.217-1.el7.elrepo       elrepo-kernel
kernel-lt-tools.x86_64                  5.4.217-1.el7.elrepo       elrepo-kernel
kernel-lt-tools-libs.x86_64             5.4.217-1.el7.elrepo       elrepo-kernel
kernel-lt-tools-libs-devel.x86_64       5.4.217-1.el7.elrepo       elrepo-kernel
kernel-ml.x86_64                        6.0.0-1.el7.elrepo         elrepo-kernel
kernel-ml-devel.x86_64                  6.0.0-1.el7.elrepo         elrepo-kernel
kernel-ml-doc.noarch                    6.0.0-1.el7.elrepo         elrepo-kernel
kernel-ml-headers.x86_64                6.0.0-1.el7.elrepo         elrepo-kernel
kernel-ml-tools.x86_64                  6.0.0-1.el7.elrepo         elrepo-kernel
kernel-ml-tools-libs.x86_64             6.0.0-1.el7.elrepo         elrepo-kernel
kernel-ml-tools-libs-devel.x86_64       6.0.0-1.el7.elrepo         elrepo-kernel
perf.x86_64                             5.19.12-1.el7.elrepo       elrepo-kernel
python-perf.x86_64                      5.19.12-1.el7.elrepo       elrepo-kernel

From your output, look at the right-hand column, and notice a series of letters and numbers (which looks something like ‘5.4.217-1.e17.elrepo’). This is the kernel version.

Use these two pieces of information to decide which kernel version you want to install. As you can see, the Linux 6 kernel is the latest mainline release.

Install the Latest Kernel on Centos 7

To install the latest mainline kernel on Centos 7, run the command below:

sudo yum --enablerepo=elrepo-kernel install kernel-ml
Output
Installed:
  kernel-ml.x86_64 0:6.0.0-1.el7.elrepo

Complete!

To install the latest stable kernel, run the following command:

sudo yum --enablerepo=elrepo-kernel install kernel-lt
Output
Installed:
  kernel-lt.x86_64 0:5.4.217-1.el7.elrepo

Complete!

Reboot and Choose the New Linux Kernel

At this point, you need to reboot your server:

reboot

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.

Set the Default Kernel Version on Centos 7

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 vi /etc/default/grub

Once the file opens, look for the line that says GRUB_DEFAULT=X, and change it to GRUB_DEFAULT=0. 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:

reboot

Verify that the boot loader is set to load the latest kernel by default.

Conclusion

At this point, you have learned to Upgrade Linux Kernel to the latest on Centos 7.

Hope you enjoy it.

You may be like these articles:

Set Up Time Synchronization on Centos 7

How to create and delete users on CentOS 7

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular