A Kernel Panic happens when the kernel hits a critical error it cannot recover from — the system halts to prevent data corruption. By default, it stays frozen until someone manually reboots. The kernel.panic sysctl parameter changes this: it tells the system to automatically reboot after a specified number of seconds, which is essential for unattended servers.

Possible Values and Their Meanings

The value of the kernel.panic parameter is an integer that specifies the number of seconds after which the system should automatically reboot following a panic.

You can check and set these values using the sysctl command:

# Check the current value
sysctl kernel.panic

# Set a new value (e.g., reboot after 10 seconds)
sudo sysctl -w kernel.panic=10

To make the change permanent, you should add the corresponding entry to the /etc/sysctl.conf file or a file in /etc/sysctl.d/:

kernel.panic = 10

Here is what the different values mean:

  • kernel.panic = 0 (default value)

    • Behavior: The system does not reboot automatically. After a Kernel Panic, the system halts and waits for administrator intervention (a manual restart). This is useful for diagnostic purposes, as it allows for an examination of the error message on the screen or via a serial console.
  • kernel.panic > 0 (a positive value, e.g., 10)

    • Behavior: The system will automatically reboot after the specified number of seconds. For example, if the value is 10, the system will wait 10 seconds and then restart. This is the most commonly used option on production servers, where a quick return to operation is a priority.
  • kernel.panic < 0 (a negative value, e.g., -1)

    • Behavior: The system will reboot immediately, without any delay. This option is used in highly critical systems where every second of downtime matters, and a delay for a memory dump (kdump) is not required.

On production servers, setting kernel.panic to a small positive value (e.g., 5 or 10) is standard practice.