How to make Linux automatically reboot after a kernel panic?

After a kernel panic, it is impossible to remotely connect to the Linux server to reboot it by SSH. How to make the panic kernel automatically reboot itself?

related to an answer for: Force Linux to reboot
asked Jan 19, 2015 by Eric Z Ma (44,280 points)

1 Answer

 
Best answer

Linux kernel has a nice feature that reboots itself after a timeout when a kernel panic happened.

Usually, it is disabled by default. To turn it on, you can set the kernel.panic kernel parameter.

For a running system:

# echo 20 >/proc/sys/kernel/panic

Here, 20 is the number of seconds before the kernel reboots. 0 means the feature is disabled.

To make the configuration persistent, you have 2 choices:

  1. add the kernel parameter panic=20 to your bootloader (grub or grub2).

  2. add kernel.panic = 20 to /etc/sysctl.conf .

After you enabled the auto reboot after kernel panic, you may need to check the uptime and logs or create a @reboot cron jobs to send emails or use some other mechanisms to know that there was a auto reboot caused by a kernel panic.

answered Jan 19, 2015 by Eric Z Ma (44,280 points)
edited Jan 30, 2015 by Eric Z Ma

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...