Use updated kernel in CentOS 7

0 Flares Twitter 0 Facebook 0 LinkedIn 0 Email -- 0 Flares ×

CentOS is known for not using the latest versions of the Linux kernel. If you need up-to-date versions, you need to configure the OS to use different repositories.

The turtle and the hare

Among the different linux distributions, I’ve always liked and used CentOS. It’s a great solution, it helps also to learn RedHat in case one would have to work with it, and has tons of resources available online to learn and get help. But one of the limits in CentOS has always been the lack of up-to-date kernels. This article has been written in November 2015, and while the latest stable kernel of Linux is 4.2.6:

Linux kernels as of November 2015

Available Linux kernels as of November 2015

on a completely up-to-date CentOS 7 machine, the used kernel is quite older:

Note, I’ve not said “outdated”, if you look at the list 3.10 is there as “longterm”. It’s good for production environments to use really stable and tested versions of the kernel, but I use a lot technologies like Ceph and BTRFS, and for those to work properly it’s recommended to use the latest possible kernels, as enhancements to those software is made available as kernel is updated. For example, I was facing an issue with the rebalancing of a BTRFS partition spread among different disks, and I found a fix was made available in kernel 3.14. So, I had to find a way to have newer kernels in my CentOS machines.

Install newer kernel on CentOS

As the main repository of CentOS has no newer version of the kernel, we need first of all to use a 3rd party repository. New kernels for CentOS are available via “ELRepo”.
First, we download the GPG key of ELRepo and install the elrepo-release package.

Now, we enable the repository (vi /etc/yum.repos.d/elrepo.repo and set enabled to 1 for [elrepo-kernels] ); then, we need to remove the old kernel headers to avoid conflicts:

and finally ask yum to install the new kernel packages:

Yum offers us to install the 4.3 version (as of November 2015). Now, we check how the different kernels are listed in the GRUB configuration file:

As we want the newer 4.3 kernel to be used by default, we tell grub to do so (0 is the first entry of the list)

After a reboot, we will have our CentOS machine using the latest kernel: