Reboot Linux box after a kernel panic

Posted on in Categories CentOS, Debian Linux, Gentoo Linux, Hardware, Howto, Linux, RedHat/Fedora Linux, Tips, Troubleshooting, Tuning last updated November 16, 2007

If you want the server to get rebooted automatically after kernel hit by a pain error message, try adding panic=N to /etc/sysctl.conf file.

It specify kernel behavior on panic. By default, the kernel will not reboot after a panic, but this option will cause a kernel reboot after N seconds. For example following boot parameter will force to reboot Linux after 10 seconds.

Open /etc/sysctl.conf file

# vi /etc/sysctl.conf

When kernel panic’s, reboot after 10 second delay

kernel.panic = 10

Save and close the file. Alternatively, you may want to enable and use magic system request keys (SysRq).

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Share this on (or read 4 comments/add one below):

4 comment

  1. Thanks for this tip! As indicated by mangoo: To take this change effect right now, issue the command
    sysctl -p to re-read the /etc/sysctl.conf
    Otherwise, this change is not active before the next reboot.

  2. It’s important to mention that there is another “key” named “panic_on_oops” that should also be defined to some amount of seconds to reboot kernel on an “oops” kind of panic. I had this situation and the console had frozen and not even SYSRQ could restart the machine. The crash dump couldn’t be saved because I had to remove power from device (embedded device without reset button) to restart it and the power off procedure avoids memory to be saved after panic.
    Making “echo 1 > /proc/sys/kernel/panic_on_oops” or “kernel.panic_on_oops=1” on /etc/sysctl.conf solved my problem of restarting after this oops panic.

Leave a Comment