Hamsa K
6 min read | 2 years ago

How to Upgrade Kernel Version on Centos 7

Install or upgrade kernel version on centos 7

The kernel is the core of an operating system.kernel acts as interface between the hardware and the software running on the system and effectively manage the resources.By default, CentOS 7 uses an old version of kernel, which is 3.10.x.

kernal version on centos manual we will install the latest stable kernel version.

[root@centos ~]# uname -sr
Linux 3.10.0-862.el7.x86_64
[root@centos ~]# cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core) 

First we need to enable elrepo repository.

ELRepo is a community-based repository for Enterprise Linux and supports for RedHat Enterprise and other distribution based like CentOS, Scientific, and Fedora.

Add ELRepo gpg key to the server.For reference you can check this URL.

[root@centos ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@centos ~]# yum install https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm 

Now ELRepo repository has been added to CentOS 7 server.

Once the repository has been enabled, you can use the following command to list the available kernel related packages.

[root@centos ~]# yum list available --disablerepo='*' --enablerepo=elrepo-kernel

sample output

Long term support kernel package name is kernel-lt version 4.4.190

Mainline stable kernel package name is kernel-ml version 5.2.11

Here I am installing the latest mainline stable kernel like below

[root@centos ~]# yum --disablerepo='*' --enablerepo=elrepo-kernel install kernel-ml
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * elrepo-kernel: ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:5.2.11-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================== Package Arch Version Repository Size

Installing: kernel-ml x86_64 5.2.11-1.el7.elrepo elrepo-kernel 48 M

Transaction Summary

Install 1 Package

Total download size: 48 M Installed size: 215 M Is this ok [y/d/N]: y Downloading packages: kernel-ml-5.2.11-1.el7.elrepo.x86_64.rpm | 48 MB 00:00:15
Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : kernel-ml-5.2.11-1.el7.elrepo.x86_64 1/1 Verifying : kernel-ml-5.2.11-1.el7.elrepo.x86_64 1/1

Installed: kernel-ml.x86_64 0:5.2.11-1.el7.elrepo


We hope you are following "How to Upgrade Kernel Version on Centos 7" step by step carefully. The remaining steps will help you to finish the upgrade process..

Now reboot server to check whether its booting from new kernel

[root@centos ~]# reboot

and then select latest kernel from the menu while rebooting and check kernel version after reboot with following command

root@centos ~]# cat /proc/version
root@centos ~]# uname -a

set default kernel version in grub

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

[root@centos ~]# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (5.2.11-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core)
2 : CentOS Linux (0-rescue-8bd7796e1b3b45b396ce37d9e088d83b) 7 (Core)

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

[root@centos ~]# grub2-set-default 0

otherwise edit below file and change as GRUB_DEFAULT=0

[root@centos ~]# vi /etc/default/grub

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

[root@centos ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.2.11-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.2.11-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-862.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-8bd7796e1b3b45b396ce37d9e088d83b
Found initrd image: /boot/initramfs-0-rescue-8bd7796e1b3b45b396ce37d9e088d83b.img

Now you can reboot server and check kernel version again.

[root@centos ~]# reboot

 Removing old kernel (optional)

If everything working fine then you can remove old kernel with following commands.

[root@centos ~]# rpm -qa | grep kernel
[root@centos ~]# package-cleanup --oldkernels
Loaded plugins: fastestmirror, langpacks
    No old kernels to remove
[root@centos ~]# yum remove kernel-3.10.0-862.el7.x86_64

Thats it. You have upgraded your kernel in CentOS 7.



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy