How to Reload New Kernel Without Complete Reboot in CentOS/RHEL

We all know that it is possible to update the kernel with a server reboot but, a restart is needed in order to make use of the new kernel (reload new kernel). Until you restart, you will still be using the old kernel you booted into when you started the server prior to updating the kernel.

Though it is not possible to reload a new kernel without a reboot, it is possible to minimize the time required to reboot a server. In this post, we are going to see how to minimize the time required for rebooting a server. We are going to see a method that will skip the hardware initialization process thus reducing server reboot time.

Step 1: Make sure kexec-tools package is installed on server. If not, use below command to install the same.

# yum install kexec-tools

Step 2: Check the current version of the kernel being used and list down all installed kernels.

# uname -r
2.6.32-573.el6.x86_64
# rpm -q kernel
kernel-2.6.32-573.el6.x86_64

Here, the server is currently using kernel version 2.6.32-573.el6.x86_64.

Step 3: Update the Kernel:

# yum update kernel

Step 4: Check Updated kernel’s version:

# rpm -q kernel
kernel-2.6.32-573.el6.x86_64
kernel-2.6.32-696.16.1.el6.x86_64

Step 5: Load new kernel.

# kexec -l /boot/vmlinuz-2.6.32-696.16.1.el6.x86_64 --initrd=/boot/initramfs-2.6.32-696.16.1.el6.x86_64.img --reuse-cmdline

Here, -l : Load the specified kernel into the current kernel. –initrd: New kernel’s initrd-image.

Step 6: Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown.

# kexec -e