Linux : Loading new kernel without “really” rebooting the server – CentOS

This is VERY interesting article I found on the internet. 
Thanks to KoRoVaMiLK#

You have that server you can’t reboot but need to patch the kernel NOW (eg. #kernel flaw found#).. well, you can try this out.

First of all, we print out running kernel version:

# uname -r

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 var:

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

# echo $latestkernel

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

..and.. wow, we lost the system! ..Well, not exactly.

The system will “restart without restarting”..something like a fast reboot, without performing BIOS checks (and you know how long can a full system restart last).

# uname -r

It worked!

* Be aware that kernel reset will perform a connection reset as well, together with resetting your uptime, so if you’re searching for something to grant your uptime record while security patching, well, this is not for you.


Credit to :


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s