How to Upgrade Linux Kernel to Stable 4.7 on CentOS 7

This is an article on upgrading Linux kernel to the latest stable version (4.7.0) on CentOS 7 . Here, we will understand why we should upgrade the kernel  and different ways of doing the same.

As you might know, kernel is a part of the Operating System(OS) that acts as an interface between applications and hardware. Linux OS being highly modular, we can customize it very easily by adding features that we need and removing the ones that are not required anymore. This lets us change the kernel with ease and hence updates are very common to it. There are various reasons as to why we should update our kernels frequently, the most important ones being

a. Security - Security flaws keep getting fixed in the latest versions

b. Stability - It is important for the system to run smoothly without any crashes and hangs. Kernel upgrades help in decreasing the chances of a system crash.

c. Efficiency -  Kernel updates focus on efficiency and speed.

d. New features - With the world around us changing so rapidly, new features and capabilities become the order of the day. In order to stay up-to-date, it becomes important for us to incorporate those features so that applications can take advantage of them.

Linux Stable Kernel 4.7

Latest stable version of the Linux Kernel i.e 4.7 was released on 24th July 2016. A plethora of new features have been added to it. In the upcoming sections, let us learn how to upgrade to this release.

Warning: Before proceeding with upgrading the kernel on your system, please backup all your important data on an external drive as the upgrade might make the system unstable at times.

Upgrade using ELRepo

ELRepo is an RPM repository of Enterprise Linux Packages which supports RHEL and its derivatives like CentOS. Let us check the version of kernel that we currently have using the command 'uname -r':

[root@li900-251 ~]# uname -r

This needs to be updated to v4.7. Enable the ELRepo and proceed with the upgradation by executing the below command:

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

This will automatically install the latest kernel for CentOS 7. The sample output will be as shown:

[root@li900-251 ~]# yum --enablerepo=elrepo-kernel install kernel-ml
Loaded plugins: fastestmirror
base | 3.6 kB 00:00
elrepo | 2.9 kB 00:00
elrepo-kernel | 2.9 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/3): updates/7/x86_64/primary_db | 5.7 MB 00:00
(2/3): elrepo/primary_db | 454 kB 00:01
(3/3): elrepo-kernel/primary_db | 1.6 MB 00:01
Loading mirror speeds from cached hostfile
* base:
* elrepo:
* elrepo-kernel:
* extras:
* updates:
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:4.7.0-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

Package Arch Version Repository Size
kernel-ml x86_64 4.7.0-1.el7.elrepo elrepo-kernel 39 M

Transaction Summary
Install 1 Package

Total download size: 39 M
Installed size: 175 M
Is this ok [y/d/N]: y
Downloading packages:
kernel-ml-4.7.0-1.el7.elrepo.x86_64.rpm | 39 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : kernel-ml-4.7.0-1.el7.elrepo.x86_64 1/1
Verifying : kernel-ml-4.7.0-1.el7.elrepo.x86_64 1/1

kernel-ml.x86_64 0:4.7.0-1.el7.elrepo


Upgrade by compiling the source

Installing dependencies

There are certain packages that are needed to compile the Linux kernel. We need to install them if not already installed.

$ yum install gcc ncurses ncurses-devel

Now, we will upgrade all the software in the system using just one command.

$ yum update

Downloading packages

We can either download the latest kernel version using 'wget' command or directly download it from  Here we will download it into /tmp directory using wget.


Downloading kernel


As the downloaded file will be in the compressed format, we need to extract it before compiling it. Let us download it into /usr/src directory.

$ tar -xf -C

[root@li900-251 tmp]# tar -xf linux-4.7.tar.xz -C /usr/src/
[root@li900-251 tmp]# cd /usr/src/linux-4.7/
[root@li900-251 linux-4.7]#


New Configuration

Switch to the directory where you extracted the kernel source (usr/src/linux-4.7) If you are compiling the kernel for the first time or want new features on top of the existing one, run the make menuconfig command in a terminal to configure all the required features in your Linux kernel.  A window as shown below pops up with multiple menus inside  some of them. Once you select the required configurations, select the 'Save' option and exit. If you want to exit without saving anything, press 'Esc' key twice.

Kernel Config options

Old Configuration

If you want to retain old configuration for the kernel, then just execute the below command:

# make oldconfig

This will save the existing configuration to .config file and you can proceed with the compilation

[root@li900-251 linux-4.7]# make oldconfig
scripts/kconfig/conf --oldconfig Kconfig
# using defaults found in /boot/config-3.10.0-327.22.2.el7.x86_64


# configuration written to .config

Compilation and Installation

In order to compile the kernel, we need to execute the make command. It generally takes around 30 minutes to compile the kernel depending on the system's configuration.  Sometimes, it is possible that you get error messages while compiling if any of the packages are missing. For example, when I was compiling, I got errors like 'bc command not found' and 'opensslv.h No such file or directory'. The first error was resolved by installing 'bc' (yum install bc) and the second by installing 'openssl-devel'(yum install openssl-devel) packages.


Once the kernel compilation is completed it is ready to be installed on the system by executing the command below:

# make modules_install install

This command will compile the modules, install the binaries into /boot directory and also adds an entry for this kernel in the grub.conf file.


Reboot your system after installing the new kernel and once the system is up, execute uname -r command to verify if the kernel version has been successfully updated.

[root@li900-251 ~]# uname -r


Congratulations! You have now upgraded your kernel to the latest version.  In this article, you have learnt two ways of upgrading the kernel. It may be wise to upgrade it from time to time to catch up with new features and bug fixes.  It is always recommended to use the ELRepo method for upgradation unless you are a developer , tester or a distro packager. Get going with the latest and the greatest version and enjoy the benefits it has to offer you!

B N Poornima 3:00 am


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


  1. Hello,
    I use centos7, and upgraded to 14.4 , though I didn't used the existing config, but another one.
    I recently noticed that initramfs might not run in my system (there is no /run/initramfs folder).
    Does it mean something is missing in my kernel ? or wrong custom defione in GRUB ? (strangely, even if I omit the line initrd /, Linux still boots ?!

    Is there any idea what has happened , and how to fix it ?