How to reboot automatically after kernel panic

Last updated on July 31, 2020 by Dan Nanni

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.

Method One: GRUB

The first method is to add "panic=<num_seconds>" as a kernel boot parameter in the GRUB configuration file, where <num_seconds> is the number of seconds to wait before automatic reboot when kernel panic has occurred.

Refer to this tutorial for instructions on adding a boot parameter to GRUB.

Method Two: sysctl

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

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

Don't forget to reload the modified sysctl.conf settings by running:

$ sudo sysctl -p /etc/sysctl.conf

Method Three: /proc

As another way to reboot automatically after kernel panic, you can also leverage the /proc filesystem and 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.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean