How to reboot automatically after kernel panic

There are cases where you encounter kernel panic. Kernel panic may occur while you are playing with some experimental kernel module that someone else wrote, or developing a custom kernel module yourself. Kernel panic can happen due to hardware failure as well. If you would like to reboot your system automatically after kernel panic has occurred, there are three different ways to do it.

As shown below, the first method is to add "panic=<num_seconds>" in the grub configuration file, where <num_seconds> is the number of seconds to wait before automatic reboot when kernel panic has occurred.

$ sudo vi /boot/grub/menu.lst
title           Debian GNU/Linux, kernel 2.6.35
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.35 root=/dev/sda1 ro quiet panic=10
initrd          /boot/initrd.img-2.6.35

The second method is to edit sysctl.conf file to include kernel.panic parameter as follows.

$ sudo vi /etc/sysctl.conf
kernel.panic = 10
$ sudo sysctl -p /etc/sysctl.conf

Finally, in order to reboot automatically after kernel panic, you could also leverage the /proc filesystem to update a related kernel parameter as follows.

$ sudo echo 10 > /proc/sys/kernel/panic

Note that unlike the first two methods, this method does not remain effective across reboots, since any update to the /proc filesystem is not persistent across reboots.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

One thought on “How to reboot automatically after kernel panic

Leave a comment

Your email address will not be published. Required fields are marked *