This article describes how to check and upgrade the Linux kernel in OpenVZ, KVM, and Dedicated Servers (including the CloudLinux platform).
To check system parameters such as the kernel version and build date, OS architecture, hostname, etc., you can use the
uname command, which is included in coreutils package:
# uname -rv 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Jan 4 01:06:37 UTC 2018
To view the current kernel version and build date, run
uname -r. Depending on the platform your server is running on, you may see slightly different output, even for the same CentOS 7 operating system.
If you run a VPS (Virtual Private Server) as an OpenVZ container, you will see the "stab" in the kernel version:
# uname -r 2.6.32-042stab125.5
If you run CentOS 7 on a Dedicated Server or a KVM virtual server, you could see "el7" in the kernel version, which refers to Red Hat Enterprise Linux, from which CentOS is derived:
# uname -r 3.10.0-693.11.6.el7.x86_64
If you are running CloudLinux, you could see "lve" in the kernel version:
# uname -r 3.10.0-714.10.2.lve1.5.9.el7.x86_64
Another way to check would be with the following yum command:
yum info kernel -q
This command may run noticeably longer, because yum uses a python interpreter and one or more plugins by default. However, it gives more detailed information. Here is an example of possible output from this command:
# yum info kernel -q Available Packages Name : kernel Arch : x86_64 Version : 3.10.0 Release : 693.11.6.el7 Size : 43 M Repo : updates/7/x86_64 Summary : The Linux kernel URL : http://www.kernel.org/ License : GPLv2 Description : The kernel package contains the Linux kernel (vmlinuz), the core of any : Linux operating system. The kernel handles the basic functions : of the operating system: memory allocation, process allocation, device : input and output, etc.
If you have a VPS as an OpenVZ container, it is not possible to upgrade your kernel independently, because all virtual containers run the same kernel loaded on the node. Therefore, voluntary upgrade can be performed only on Dedicated Servers and KVM-based virtual servers.
To upgrade the kernel, you can run this
yum upgrade kernel
By default, this command should ask for confirmation to install new kernel:
Is this ok [y/d/N]:
If you want to skip the confirmation, you can use the
yum upgrade kernel -y
Once the new kernel is installed you need to load it. To do so, you need to reboot the server:
Once the server has finished rebooting, you should check the loaded kernel version as described in previous section.
KernelCare is a live-patching software for Linux kernels distributed by CloudLinux. When using KernelCare, the server does not require rebooting for kernel upgrades, and kernel patches are checked and applied on the fly automatically every 4 hours. It is available only for Dedicated Servers and KVM virtual servers.
You can check if KernelCare is installed as follows:
# yum info kernelcare -q Installed Packages Name : kernelcare Arch : x86_64 Version : 2.14 Release : 2 Size : 217 k Repo : installed From repo : kernelcare Summary : KernelCare tools URL : http://www.cloudlinux.com License : CLOUD LINUX LICENSE AGREEMENT Description : KernelCare userland tools
To check if patches have been applied, run:
More details about KernelCare can be found in the following places:
Sometimes you may need to remove old kernels from the server manually. To check all installed kernels, this
yum command could be used again:
# yum list kernel -q Installed Packages kernel.x86_64 3.10.0-693.11.1.el7 @updates kernel.x86_64 3.10.0-693.11.6.el7 @updates
Using the command
package-cleanup with the
--oldkernels switch would remove all old kernels, leaving only 'count' most recent ones (by default count=2). For example, to remove all kernels except the one most recently installed and loaded, run the following command:
package-cleanup --oldkernels --count=1