2

I normally would test whether sysrq + sub works when the kernel panic occurs, but "unfortunately" my system works pretty stable, and I have no idea how to make kernel panic. So the question is very simple. Does sysrq work when the kernel panics, or do I have to reboot the machine by using the reset button?

A bonus question: When the kernel reboots the system via the kernel.panic sysctl parameter, is it the exact same situation compared to pressing the reset button? Does the kernel make any actions before restarting the system, for instance sync or remount read-only?

  • Without testing, I believe kernel panic shuts down all kernel functions, including the magic sysrq. The water is muddied somewhat by all the kernels which don't have sysrq support enabled by default. – Tom Hunt Oct 28 '15 at 21:49

1 Answers1

4

You should be able to generate a panic using:

sysctl kernel.panic=1
sysctl kernel.sysrq=1
echo c > /proc/sysrq-trigger

See the kernel documentation for details on the kernel.sysrq parameter and the 'c' command

The kernel.panic=1 parameter is to set to have the host to reboot after 1 second when a panic occured. If you want to investigate console output you might want to set the parameter to 0 to prevent the automatic reboot.

Stephen Kitt
  • 434,908
Lambert
  • 12,680
  • 2
    I've just tested echo c > /proc/sysrq-trigger and it looks like the kernel panics, but my desktop was frozen, I mean there was no console. I have 60 set in the kernel.panic parameter and after that time the machine was rebooted. So it looks like it works. Anyways, sysrq doesn't work at all. :) – Mikhail Morfikov Oct 28 '15 at 22:20
  • https://www.kernel.org/doc/Documentation/sysrq.txt gives a 404. – Aaron Franke May 13 '18 at 15:07
  • https://www.kernel.org/doc/Documentation/admin-guide/sysrq.rst is the new location – Eric Sep 03 '19 at 16:35
  • @Eric , thanks, I've edited the answer and updated the link – Lambert Sep 04 '19 at 14:19