Installing the latest mainline kernel on CentOS 6 & 7 Print

  • 15

Many customers wish to use the latest Mainline Linux kernel on their CentOS boxes due to the additional performance and - potentially - stability under load, that it might offer. Here is how we can achieve this:

1. We're going to use the mainline kernels precompiled and made available by ELRepo. Firstly, we need to enable their repo on the CentOS box.
2. Then, we're going to actually install the kernel using yum - very simple.
3. Finally, we'll edit grub.conf to ensure the server reboots to the latest kernel, and then we'll be good to go.
4. Before you start, please make sure you have console or VNC access to your server in case you need to boot back to an older kernel version!

CentOS 7
Run the following commands via SSH:

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml -y

Now we need to set grub_default to 0 in the configuration, to automatically boot to the newest kernel:

nano /etc/default/grub

GRUB_TIMEOUT=5
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

Finally, we set the default kernel, rebuild grub with the latest configuration and then reboot the server.
grub2-set-default 0
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot

If the server does not reboot, check the console/VNC and correct any errors, or reboot to an older kernel and contact your IT admin.

If the server reboots, but using the wrong kernel (check with uname -a) then you might need to populate the /etc/default/grub file with defaults, and rebuild grub2 config with "grub2-mkconfig -o /boot/grub2/grub.cfg". Please check this page for more information: https://wiki.centos.org/HowTos/Grub2

CentOS 6
Run the following commands via SSH:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml

Now we need to edit /etc/grub.conf and change "default=1" to "default=0" to automatically boot to the latest kernel. Once done, issue the reboot command and check the kernel version (uname -a) once the server comes back.

If the server does not reboot, check the console/VNC and correct any errors, or reboot to an older kernel and contact your IT admin.

Source: http://elrepo.org/tiki/kernel-ml

Was this answer helpful?

« Back