Installing the Linux Kernel 4.x on CentOS 7

Step 1 - Find current kernel version

Run the following command to know your current kernel:

uname -sr


Kernel Version

Step 2 - Enable ELRepo

To enable the ELRepo repository on CentOS 7, do:

rpm --import
rpm -Uvh



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

yum --disablerepo="*" --enablerepo="elrepo-kernel" list available


Kernel Packages

Step 3 - Install kernel

Run the following command to install the latest mainline stable kernel:

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


Kernel Packages

To make the newly-installed version the default boot option, you will have to modify the GRUB configuration as follows:

Open and edit the file /etc/default/grub and set GRUB_DEFAULT=0. This means that the first kernel in the GRUB list will be used as default.

vi /etc/default/grub

To insert/edit the file enter 'i' for insert mode and insert the following at End Of Fle. After inserting, save the file by hitting Esc key and then ':' [colon] followed by wq and enter



Grub config

Step 4 - Kernel configuration

Run the following command to recreate the kernel configuration:

grub2-mkconfig -o /boot/grub2/grub.cfg



Step 5 - Verify the kernel version

Reboot and verify that the latest kernel is now being used by default using the uname command again:

uname -sr


Kernel version

You have upgraded your system kernel to the latest version available!