CentOS is not up-to-date with kernel versions, but not because it doesn’t care, it’s because it has some internal policy that implies that system stability is ahead of the newer features of a newer kernel version…

CentOS is primarily a Linux distribution designed for servers, so for example, recognizing a newer audio or network card is not a priority, but if there is a security flaw within the existing kernel version – CentOS and Red Het will release updates through a standard repository that can be installed with simple yum update, not from ‘zero’ as it will be here in this tutorial.

With this instruction, I will just briefly go through the process of installing the currently latest kernel (on 20/10/2017 when this instruction is written, the latest version was labeled 4.13.8) without any additional changes (check the released versions), deeper configurations, eject unnecessary things and choosing options through a configuration file. I will do an installation on CentOS 7 Minimal with a yum update -y done. If you are doing a kernel update please make a backup system – just for any case, or if you use some kind of virtualization, do a snapshot of the system, and if after a while there are no problems in the work … you can delete a snapshot – surely if the kernel does not show up well you can always boot system from the older kernel and pretend where were nothing bad happens.

The manual installation of the new kernel will take a long time (it may take several hours) so do not be surprised – the system is doing normal for that time because you are booted into the current kernel and as long as it is there, there is no worry. In some of the future posts, I will set up the installation process in an easier way, through the elrepo-kernel repository.

Of course, my recommendation is to update the kernels only from the official CentOS repo (base and updates repos) because these versions have been tested and tested in the work by CentOS dev team so the chance to something goes bad is almost zero…. So, with the guidance given below, you work only if you really need latest kernel for some reason. The team behind CentOS will definitely publish a newer version if the existing one has some problems that can affect stability or security.

# Installing the required packages for the kernel compilation process
yum install wget gcc make ncurses-devel openssl-devel elfutils-libelf-devel bc perl -y

# Kernel download
mkdir -p /usr/src/kernels/
cd /usr/src/kernels/
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.13.8.tar.gz
tar xvf linux-4.13.8.tar.gz
rm -f linux-4.13.8.tar.gz
cd linux-4.13.8

# Config file creation based on last one
cp $( ls -1t /boot/config-* | head -1) .config

# Start menu selection for options. For now, just choose Save
make menuconfig

# Launching the kernel upgrade process (it may take several hours)
make -j `nproc` && make modules_install && make install

# After installation, restart the server to see if there is a new kernel
reboot

After the restart, I see a new kernel in the offer – but it was not default one – it was still getting old stuff … so this should change this, to start from new one by default.

There is a new kernel – but it is not default

The process of setting up a new startup kernel is quite simple (although there are more complicated ways) – you just need to find line number of the kernel in the file /etc/grub2.cfg and simply place it with regular command. Be careful – counting starts from zero, so the first kernel starts with number 0 (not 1).

# To see which is our kernel, the order starts from zero
grep "menuentry '" /etc/grub2.cfg

# Lets set our kernel (number 0) to be default 
grub2-set-default 0

# And do a restart to check this change and does system now start from the new kernel
reboot

Now it’s OK, our kernel is a default

If you do not have access to the display or console, you can check the kernel version of the command: uname -r

Our new kernel