Using Linux Kernel SysReq

The SysReq feature of the Linux kernel allows for special system requests to be sent to the kernel. This can be useful to get the kernel to do things that it wouldn't normally do for testing purposes. As I write this, I am trying to test the kdump feature of the kernel, which dumps the kernel memory when the kernel crashes. Using this feature I am able to cause a kernel crash by doing the following:

echo 1 > /proc/sys/kernel/sysrq
echo c > /proc/sysrq-trigger

You can press Alt + SysRq + c (or whatever the character is that is listed below) to do the same thing, but on two out of the three systems I just tried this on it failed to work. It definitely does not work from within the GUI, as it triggers a Print Screen instead.

Besides just getting the kernel to crash, there are the following other system requests:

m: memory allocation information
t: thread information
p: CPU register and flag informationo
s: sync mounted filesystems
u: unmount all filesystems
b: reboot immediately
o: poweroff immediately

When the request is to do something to display information, then this data is typically dumped to /var/log/messages.

To permanently enable system requests, add to /etc/sysctl.conf the following:
kernel.sysrq = 1
To make system requests immediately available, run 'sysctl -p' as root or reboot.

No comments:

About Me - WrightRocket

My photo

I've worked with computers for over 30 years, programming, administering, using and building them from scratch.

I'm an instructor for technical computer courses, an editor and developer of training manuals, and an Android developer.