How to Upgrade Kernel on CentOS 7

The Kernel is the brain for an operating system. It’s like the core element of every OS. Speaking of Linux, the Linux kernel – created by Linus Torvalds – is a monolithic, Unix-like kernel. Some popular OSs that use the Linux kernel are Ubuntu, CentOS, and Debian.

In this tutorial, I will show you how to upgrade CentOS 7 kernel to the latest version, and we will be using the kernel from ELRepo repository. CentOS 7 is using 3.10 as the default kernel version. And in this guide, we will install the latest stable version 5.2.0.

How to Upgrade Kernel on CentOS 7

What is ELRepo?

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

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

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 latest versions with the yum command below.

yum -y update

Now install the following package to make installation and updating process fast.

yum -y install yum-plugin-fastestmirror

Checking kernel version

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

cat /etc/centos-release

You will get the system info as shown below.

linux kernel

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

uname -msr

The output will show your machine’s Linux kernel version as well system architecture.

Add ELRepo Repository

Before installing new kernel version, we need to add new repository ELRepo repository. That’s because we want to use the kernel version from the ELRepo community.

Add ELRepo gpg key to the system.

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
  • To install ELRepo for RHEL-7, SL-7 or CentOS-7:
yum install https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
  • To install ELRepo for RHEL-6, SL-6 or CentOS-6:
yum install https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm

Next, check all repositories enabled on the system, and make sure ELRepo is on the list.

yum repolist

linux kernel

ELRepo repository has been added to the CentOS 7 server.

Install new Kernel version

In this step, we will install latest kernel version (5.2.0 – the Latest stable version on kernel.org) from the ELRepo repository.

Use the following yum command for this.

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

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

Configure Grub2

At last step, we’ve already installed a new kernel 5.2.0 to the system. Now we will show you how to make it the default kernel version that will load when the system is starting.

Check all available kernel versions with the awk command below.

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

In the output, you’ll see that we’ve four kernel versions.

We want to use kernel 5.2.0 as our default, so you can use the following command to make this happen.

grub2-set-default 0

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

linux kernel

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

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

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

uname -msr

linux kernel

Remove old kernel (optional)

This is an optional step that we think you need in order to get more free space. In this step, we will show you how to remove an old kernel from your CentOS 7 system. This can be done when you have several 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 following command.

package-cleanup --oldkernels

f you get the result below.

linux kernel

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

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

0 0 votes
Article Rating
赞(1) 打赏
未经允许不得转载:iemblog » How to Upgrade Kernel on CentOS 7
Subscribe
Notify of
guest

0 COMMENTS
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
免责声明:本站大部分下载资源收集于网络,只做学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除,若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,与本站无关。本站发布的内容若侵犯到您的权益,请联系站长删除,我们将及时处理! Disclaimer: Most of the download resources on this site are collected on the Internet, and are only used for learning and communication. The copyright belongs to the original author. Please consciously delete within 24 hours after downloading. If you use it for commercial purposes, please purchase the original version. If the content posted on this site violates your rights, please contact us to delete it, and we will deal with it in time!

联系我们 Contact us

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

0
Would love your thoughts, please comment.x
()
x