How to early configure Linux kernel to reboot on panic?
From man proc
:
/proc/sys/kernel/panic
This file gives read/write access to the kernel variable panic_timeout. If this is zero, the kernel will loop on a panic; if nonzero it indicates that the kernel should autoreboot after this number of seconds. When you use the software watchdog device driver, the recommended setting is 60.
The config file is boot (grub) configuration file itself, since it is a parameter invoked at the boot time and grub cannot be expected to read from some other config file while the filesystem is not mounted.
However, that being a initialized setting, the runtime can also be modified through sysctl
. So, essentially updating /etc/sysctl.conf
with parameter kernel.panic = 3
is a configuration update.
There does not seem to be such a config option. The default timeout is 0 which according to http://www.mjmwired.net/kernel/Documentation/kernel-parameters.txt#1898 is "wait forever".
The option is defined in kernel/panic.c, you can write a patch that sets the initial value to something different.
To hardcode a reboot after 3 seconds, change:
int panic_timeout;
to:
int panic_timeout = 3;