How to Upgrade the Linux Kernel on CentOS Server

How to Install WordPress – Complete WordPress Installation Tutorial
May 3, 2017
Install cPanel & WHM on AWS EC2 Instance
Install cPanel & WHM on AWS EC2 Instance
December 16, 2019

How to Upgrade the Linux Kernel on CentOS Server

how to upgrade kernel in centos 7

how to upgrade kernel in centos 7

How to Upgrade the Linux Kernel on CentOS 7 Server

The kernel is the core of an operating system. The Linux kernel is the monolithic Unix-like kernel of the Linux computer operating system. It was created by Linux Torvalds, and all Linux distributions including Ubuntu,  and Debian are based on this kernel – the Linux kernel.

In this tutorial, I will show you how to upgrade the CentOS 7 kernel to the latest version. We will use a precompiled kernel from the ELRepo repository. By default CentOS 7 uses kernel 3.10. In this manual, we will install the latest stable kernel version 5.0.11.

What is the ELRepo

ELRepo is a community-based repository for Enterprise Linux and supports for RedHat Enterprise (RHEL) and other distribution based on it (CentOS, Scientific, and Fedora).

ELRepo has the focus on packages related to hardware, including filesystem drivers, graphic drivers, network drivers, sound card drivers, webcam, and others.

What we will do:

  1. Update and Upgrade CentOS 7
  2. Checking the Kernel Version
  3. Add ELRepo Repository
  4. Install New Kernel Version
  5. Configure Grub2
  6. Remove Old Kernel
Check how to install cPanel on Google Cloud Platform.

Step 1 – Update and Upgrade CentOS 7

The first thing we must do before upgrading the kernel is to upgrade all packages to the latest version. Update the repository and all packages to their latest versions with yum command below.

yum -y update

Now install yum plugin to get faster when installing and updating packages.

yum -y install yum-plugin-fastestmirror

CentOS 7 System updated and all packages upgraded to the latest versions.

Upgrade the Linux Kernel on CentOS 7

Step 2 – Checking the Kernel Version

In this tutorial, we will use CentOS 7.6 with default kernel 3.10. Check your CentOS version with commands below.

cat /etc/redhat-release
 cat /etc/os-release

You will get the system info below.

Upgrade the Linux Kernel on CentOS 7.6

For checking the kernel version, you can also use the uname command.

uname -snr

And you get the result about the Linux kernel version and the system architecture.

Upgrade the Linux Kernel on CentOS 7.7

Step 3 – Add ELRepo Repository

Before installing the new kernel version, we need to add a new repository – the ELRepo repository.

Add ELRepo gpg key to the system.

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

Now add a new ELRepo repository with rpm command.

rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

When it’s complete, check all repository enabled on the system, and make sure ELRepo is on the list.

yum repolist

Upgrade Linux Kernel on CentOS 7

ELRepo repository has been added to the CentOS 7 server.

Step 4 – Install New CentOS Kernel Version

In this step, we will install a new latest kernel from ELRepo repository, kernel version 5.0.11 – the Latest stable version on kernel.org.

Install ELRepo kernel version with yum command below.

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

–enablerepo is an option to enable the specific repository on CentOS system. By default, ‘elrepo’ repository is enabled, but not for the ‘elrepo-kernel’ repository.

Upgrade Linux Kernel on CentOS 7

You can check all of the available repositories on the system, enabled and disabled repository with the command below.

yum repolist all

List CentOS 7 repositories, enabled and disabled repositories.

Upgrade the Linux Kernel on CentOS

Step 5 – Configure Grub2 on CentOS 7

At step 4, we’ve already installed a new kernel 5.0.11 to the system. Now, I will show you how to configure the default kernel version to load when the system is starting.

Check all available kernel versions in the Grub2 with awk command below.

sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

You see that we have two kernel versions – 3.10 and 5.0.11.

Now we want to configure the default kernel that will run when the system is starting. We will use kernel 5.0 as our default, so you can use the command below to set it up.

sudo grub2-set-default 0

0 – it’s from the awk command on the top. Kernel 5.0.11 = 0, and Kernel 3.10 = 1. When you want to back to the old kernel, you can change the value of the grub2-set-default command to 1.

Next, generate the grub2 config with ‘gurb2-mkconfig’ command, then reboot the server.

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

Upgrade the Linux Kernel on CentOS

Please login to the server again, and check currently kernel usage.

uname -snr

Upgrade Linux Kernel on CentOS

You get a result kernel version 5.0.11 is being used on your system.

Step 6 – Remove an Old Kernel (Optional)

This is an optional step that is useful to get more free space. In this step, I will show you how to remove an old kernel from your CentOS 7 system. This should be done when you have more than 3 or 5 kernel versions installed on the server.

For this purpose, we need to install the yum-utils utility from the repository.

yum install yum-utils

Now clean your old kernel with the command below.

package-cleanup --oldkernels

If you get the result below.

Upgrade Linux Kernel on CentOS

That means you’ve only 2 or 3 Kernel versions installed. If you have more than 3 versions installed, the command will automatically remove the old kernel from your system.

CentOS 7 Kernel has been updated to the latest stable using ELRepo Kernel Version.

Check how to install cPanel on AWS.

Reference

1677 Comments

  1. erectile dysfunction reviews
    erectile implants
    is erectile dysfunction permanent

  2. When the status can capable to set up maximum number involved with software occupations around Orissa subsequently Oriya software packages qualified working hard beyond Orissa, likewise wanting to come family home talk about…

  3. HelpBot24jap says:


    Свежедобытые базы в целях брута -_- спама так же иных Любых планов.
    Мгновенное приобретение online. Онлайн Телеграм бот автопродаж @BlackFriday24_bot
    Имеются в наличии базы данных в формате майл-_-pass с доступом по IMAP / POP3 / СМТП
    Mail базы разных стран специально для рассылки Ваших предложений / спама
    С нами Выгодно работать!
    Постоянным заказчикам существенные скидки!
    Всегда в наличии свежайшие базы, а помимо прочего программы для их более успешного применения
    Ежели нужны выборки по определенным странам, обращайтесь по контактным данным телеграм бота
    Выдача в режиме он-лайн по завершении оплаты. Посодействуем с нужным приватным софтом

  4. berkey says:

    Thanks for finally talking about > %blog_title% < Liked it!|

  5. Lauretta Partible says:

    Hello everyone, i am Highly skilled SEO and linkbuilding expert. I have extreme Capability to build bulk Backlinks within a short time. If you are looking for Bulk links, then contact me or check my gig. Thanks

  6. Nice weblog here! Additionally your website a lot up fast! What host are you the usage of? Can I am getting your associate link on your host? I want my site loaded up as quickly as yours lol

  7. berkey says:

    I think the admin of this web page is truly working hard in favor of his website, as here every data is quality based information.|

  8. berkey says:

    When I initially left a comment I seem to have clicked on the -Notify me when new comments are added- checkbox and now each time a comment is added I get 4 emails with the same comment. Is there a way you can remove me from that service? Kudos!|

  9. Hi, I do believe this is an excellent blog. I stumbledupon it 😉 I’m going to come back yet again since I book marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

Leave a Reply

Your email address will not be published. Required fields are marked *