The magic sysreq options introduced

Posted by chris on Wed 1 Nov 2006 at 13:32

Tags: ,

This content is taken from the linux kernel source documentation. I'm throwing it out here to make it easier for users to find. The sysreq key is a "magical" key combination to which your Linux kernel will respond, regardless of whatever it is doing.

For full details - see the file Documentation/sysrq.txt included in the Linux kernel source code.

What is the magic SysRq key?

It is a 'magical' key combo you can hit which the kernel will respond to regardless of whatever else it is doing, unless it is completely locked up.

How do I use the magic SysRq key?

On x86
You press the key combo 'ALT-SysRq-'. Note - Some keyboards may not have a key labeled 'SysRq'. The 'SysRq' key is also known as the 'Print Screen' key. Also some keyboards cannot handle so many keys being pressed at the same time, so you might have better luck with "press Alt", "press SysRq", "release Alt", "press ", release everything.
On SPARC
You press 'ALT-STOP-', I believe.
On the serial console (PC style standard serial ports only)
You send a BREAK, then within 5 seconds a command key. Sending BREAK twice is interpreted as a normal BREAK.
On PowerPC
Press 'ALT - Print Screen (or F13) - , Print Screen (or F13) - may suffice.
On other
If you know of the key combos for other architectures, please let me know so I can add them to this section.
On all
write a character to /proc/sysrq-trigger. eg:
echo t > /proc/sysrq-trigger

What are the 'command' keys?

'r'
Turns off keyboard raw mode and sets it to XLATE.
'k'
Secure Access Key (SAK) Kills all programs on the current virtual console. NOTE: See important comments below in SAK section.
'b'
Will immediately reboot the system without syncing or unmounting your disks.
'c'
Will perform a kexec reboot in order to take a crashdump.
'o'
Will shut your system off (if configured and supported).
's'
Will attempt to sync all mounted filesystems.
'u'
Will attempt to remount all mounted filesystems read-only.
'p'
Will dump the current registers and flags to your console.
't'
Will dump a list of current tasks and their information to your console.
'm'
Will dump current memory info to your console.
'v'
Dumps Voyager SMP processor info to your console.
'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.)
'f'
Will call oom_kill to kill a memory hog process
'e'
Send a SIGTERM to all processes, except for init.
'i'
Send a SIGKILL to all processes, except for init.
'l'
Send a SIGKILL to all processes, INCLUDING init. (Your system will be non-functional after this.)
'h'
Will display help ( actually any other key than those listed above will display help. but 'h' is easy to remember :-)

 

 


Posted by Anonymous (88.161.xx.xx) on Wed 1 Nov 2006 at 14:20
Take a look on sysrqd if you want to use this via network.

[ Parent | Reply to this comment ]

Posted by Steve (80.68.xx.xx) on Wed 1 Nov 2006 at 14:44
[ Send Message | View Steve's Scratchpad | View Weblogs ]

Good tip.

Of course this does require the machine to still have a good networking stack/state .. otherwise it will fail.

Steve

[ Parent | Reply to this comment ]

Posted by Federico2 (213.140.xx.xx) on Thu 2 Nov 2006 at 15:08
[ Send Message ]
sysrqd can be very useful but be careful: the password is sent in clear text.

[ Parent | Reply to this comment ]

Posted by Anonymous (67.95.xx.xx) on Wed 1 Nov 2006 at 16:32
Good idea re-posting this here, but you need to go through and replace your angle brackets with the HTML escapes:

Alt-SysRq-<command key>

You'll notice it currently shows as "Alt-SysRq-" or similar :)

Note #2: I put the escapes into this comment, and when I hit the preview function, it replaced my escape sequences with the actual characters, so I'm leaving the semicolons off (I guess I could experiment with multiple levels of & instead, but somehow I don't think it's necessary :p)

Note #3: Argh! It's adding the semicolon by itself and then converting _that_! OK, fine...just find the bug and fix it. :)

[ Parent | Reply to this comment ]

Posted by yarikoptic (165.230.xx.xx) on Mon 6 Nov 2006 at 21:20
[ Send Message ]
and what is the right way to send sysrq into serial console?
By a mistake I found on a box that pressing Ctrl-A F and then some letter dumped me a SysRq menu but unfortunately I can't experiment right now. Is there a documentation on that?
a bit offtopic: how to send a Ctrl-Alt-Del inside the minicom console?

[ Parent | Reply to this comment ]

Posted by dkg (216.254.xx.xx) on Tue 14 Nov 2006 at 20:40
[ Send Message | View dkg's Scratchpad | View Weblogs ]
using magic sysrq over a serial console is done by sending a "break". minicom uses Ctrl-A F (assuming yer minicom escape sequence is the default Ctrl-A) to send a break.

I personally use screen instead of minicom for my serial console connections, invoked like this:

screen /dev/ttyS3 115200
Screen will send a break with C-a b (again, assuming yer still using the default C-a esc. sequence for screen).

the canonical place to look up serial console stuff is the remote serial console HOWTO, which has a page about SysRq, which states:

The serial console uses the RS-232 break function as the "magic SysRq key". A "break" is a period of no transmission on the serial line, on traditional terminals it is activated by pressing a key labeled Break.

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

Which init system are you using in Debian?






( 1062 votes ~ 6 comments )