Upgrading Centos 7 Kernel to enable using Overlay with Docker
Mon, Oct 5, 2015Context
I wanted to use Overlay storage driver for our Docker hosts (see why devicemapper should be avoided in my opinion. ).
The issue is: Overlayfs support has been merged in the Linux Kernel in 3.18 and Centos 7 is currently using a 3.10 one .[1].
Upgrade your kernel
Hence, since this is not for a customer-facing production machine, I decided to upgrade the kernel.
The simplest way to do it is to use ELRepo and install the package called 'kernel-ml' (like in kernel mainline).
TL;DR:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml
Bonus: switch grub by command line before rebooting
If you use a remote VM like me, you may not have access to the grub UI when the machine reboots. And the thing is: Centos will by default use the previous kernel.
So, by default again, if you reboot without modifying it, you will stay on the same old kernel.
If you want your machine to use the newly installed one: execute the following command (it will select the first available kernel, which is the newly installed on centos by default)
grub2-set-default 0
To show the list of available kernels, you can verify that the new one is indeed the first:
$ awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (4.1.6-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (4.1.6-1.el7.elrepo.x86_64) 7 (Core) with debugging
CentOS Linux (3.10.0-229.7.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-229.7.2.el7.x86_64) 7 (Core) with debugging
CentOS Linux 7 (Core), with Linux 3.10.0-229.el7.x86_64
CentOS Linux 7 (Core), with Linux 0-rescue-53ed95ad53094b469043c84aa868b827
Hope this helps!