Changing Kernel Panic Behavior on Linux
-
When a kernel panic is received in Linux we can either do nothing or we can reboot. Typically in a production environment we would want to reboot and hopefully return the system to a working state as quickly as possible. In a non-production environment where we are more interested in troubleshooting than in bringing services back online as quickly as we can we are more likely to want to not reboot so that we can investigate from the console while the box is still panicked.
The parameter for this behavior is stored in /proc/sys/kernel/panic. The settings are simple. A value of zero for “never reboot, just wait for intervention” and any positive integer indicating the number of seconds to wait after detecting a kernel panic before rebooting.
Let’s view our current setting:
# cat /proc/sys/kernel/panic 0
So in this case we are going to just “sit there” should the kernel panic. Now we will modify this value so that the system will automatically restart after thirty seconds once the kernel has had a panic.
# echo "30" > /proc/sys/kernel/panic # cat /proc/sys/kernel/panic 30
This is perfect for testing but the change is not permanent and will revert to default when the system restarts. To make the change permanent we need to add an entry to the /etc/sysctl.conf file.
# echo "kernel.panic = \"30\"" >> /etc/sysctl.conf
Originally found on my Linux blog: https://web.archive.org/web/20140823021548/http://www.scottalanmiller.com/linux/2011/06/22/change-kernel-panic-behavior/
-