13

Occasionally, when I resume from a suspend or hibernate state, I experience a kernel panic. In such cases, I usually force a shutdown by holding down the power button. Recently, I've started using the kernel parameter panic=n, which automatically reboots the system after n seconds following a kernel panic.

  1. Is there a difference between these methods?

  2. I’ve learned that it’s possible to load another kernel in preparation for a potential kernel panic, allowing you to save the panic logs. Can this secondary kernel be used to perform a proper shutdown (e.g., stopping systemd services, unmounting the file system, etc.) instead of a forced reboot?

ReYuki
  • 174

1 Answers1

14

Is there a difference between these methods?

No, as the original kernel has completely stopped doing kernel things at that point; literally the only things it's doing are blinking the keyboard LED and counting down that reboot timer. Nothing else is running.

Can this secondary kernel be used to perform a proper shutdown (e.g., stopping systemd services, unmounting the file system, etc.) instead of a forced reboot?

Also no. The secondary kernel won't have any of the filesystem driver's "working data" in memory, for example, nor any references to the previously existing processes – it starts fresh just like any other kernel – in part because it has no good way of knowing which of those data structures are still good vs which of them may have been corrupted by whatever issue led to the panic() to begin with, and in part because scraping such things out of a different kernel is probably too fiddly a process to be worth it.

Your filesystem will usually have its own ways of recovering from a crash, anyway, as will your SQL database and other things.

grawity
  • 501,077