Table of Contents

Magic System Request

The Magic System Request Key offers a standardized way to interact with a hanging or crashed Linux system, where the Linux kernel is still running. Through several key combinations a low level interaction with the running kernel is possible from the systems console. Such an interaction is not possible with a system that has failed due to a hardware failure or a kernel panic.

Commands

In general the key combination for the Magic System Request Key consists of Alt+SysRq and an additional key which are pressed down simultaniously. On a german keyboard layout the Magic System Request Key consists of Alt+Druck and an additional key. On laptop systems there might be an addtional press of Fn or Num necessary.

See the Linux kernel documentation Linux Magic System Request Key Hacks for a complete list of keybindings.

An overview list of keybindings.

Keybinding Description
B Will immediately reboot the system without syncing or unmounting your disks.
C Will perform a system crash by a NULL pointer dereference. A crashdump will be taken if configured.
D Shows all locks that are held. The CONFIG_LOCKDEP kernel option is required.
E Send a SIGTERM to all processes, except for init.
F Will call the OOM killer to kill a memory hog process, but do not panic if nothing can be killed.
G Used by kgdb (kernel debugger)
H Will display help (actually any other key than those listed here will display help. but H is easy to remember.
I Send a SIGKILL to all processes, except for init.
J Forcibly “Just thaw it” - filesystems frozen by the FIFREEZE ioctl.
K Secure Access Key (SAK) Kills all programs on the current virtual console.
L Shows a stack backtrace for all active CPUs.
M Will dump current memory info to your console.
N Used to make RT tasks nice-able
O Will shut your system off (if configured and supported).
P Will dump the current registers and flags to your console.
Q Will dump per CPU lists of all armed hrtimers (but not regular timer_list timers) and detailed information about all clockevent devices.
R Turns off keyboard raw mode and sets it to XLATE.
S Will attempt to sync all mounted filesystems.
T Will dump a list of current tasks and their information to your console.
U Will attempt to remount all mounted filesystems read-only.
V Forcefully restores framebuffer console.
Causes ETM buffer dump (ARM-specific)
W Dumps tasks that are in uninterruptable (blocked) state.
X Used by xmon interface on ppc/powerpc platforms. Show global PMU Registers on sparc64. Dump all TLB entries on MIPS.
Y Show global CPU Registers (SPARC-64 specific)
Z Dump the ftrace buffer
0 - 9 Sets the console log level, controlling which kernel messages will be printed to your console. (0, for example would make it so that only emergency messages like PANICs or OOPSes would make it to your console.)

A common Magic System Request Key sequence is R, E, I, S, U and B.

Configuration

The Magic System Request Key feature is controlled by the kernel configuration option CONFIG_MAGIC_SYSRQ and the kernel parameter kernel.sysrq.

A more fine-grained configuration control is possible via the file /proc/sys/kernel/sysrq. The file contains the decimal value of a bitmask. Each bit with a value of 1 enables the command associated with this bit.

The following bit to command associations exist:

Decimal value Description
0 disable sysrq completely
1 enable all functions of sysrq
2 enable control of console logging level
4 enable control of keyboard (SAK, unraw)
8 enable debugging dumps of processes etc.
16 enable sync command
32 enable remount read-only
64 enable signalling of processes (term, kill, oom-kill)
128 allow reboot/poweroff
256 allow nicing of all RT tasks

E.g. in order to enable all Magic System Request commands issue the following command:

root@host:~$ echo 1 > /proc/sys/kernel/sysrq