Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Update Linux Kernel without rebooting  (Read 1980 times)

0 Members and 1 Guest are viewing this topic.

vinayakk

  • Guest
Update Linux Kernel without rebooting
« on: December 18, 2013, 07:59:25 pm »
Every linux kernal update requires reboot.
But there is workaround for that by patching the kernel with kexec.

First of all, we print out running kernel version:

# uname -r
2.6.32-71.29.1.el6.i686

Ok, we have to patch:

# yum update kernel*

Grab the kexec tools:

# yum install kexec-tools

Now we get last installed kernel version release and put it on a variable.

# latestkernel=`ls -t /boot/vmlinuz-* | sed "s/\/boot\/vmlinuz-//g" | head -n1`

# echo $latestkernel
2.6.32-220.4.1.el6.i686

Now we need to load the new kernel version in memory:

# kexec -l /boot/vmlinuz-${latestkernel} --initrd=/boot/initramfs-${latestkernel}.img --append="`cat /proc/cmdline`"

Finally, we can issue a reset:

# kexec -e


The system will “restart without restarting”..something like a fast reboot, without performing BIOS checks.

# uname -r
2.6.32-220.4.1.el6.i686


* Be aware that kernel reset will perform a connection reset as well, together with resetting your uptime.