Difference between revisions of "Magic SysRq Key"
(Initial edition of article) |
(Reformatted with tables, added several sections and thus TOC) |
||
Line 1: | Line 1: | ||
− | + | '''Alt-SysRq-*''' 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. | regardless of whatever else it is doing, unless it is completely locked up. | ||
− | When running a kernel with SysRq compiled in ( | + | == /proc/sys/kernel/sysrq == |
− | <tt>/proc/sys/kernel/sysrq</tt> controls the functions allowed to be invoked via the SysRq key. | + | |
+ | When running a kernel with SysRq compiled in (as in all binary kernels released by OpenVZ), | ||
+ | <tt>/proc/sys/kernel/sysrq</tt> file controls the functions allowed to be invoked via the SysRq key. | ||
Here is the list of possible values in <tt>/proc/sys/kernel/sysrq</tt>:<br> | Here is the list of possible values in <tt>/proc/sys/kernel/sysrq</tt>:<br> | ||
− | + | {| class="wikitable" | |
− | + | ! 0 | |
− | + | | disable sysrq completely | |
+ | |- | ||
+ | ! 1 | ||
+ | | enable all functions of sysrq | ||
+ | |- | ||
+ | ! >1 | ||
+ | | bitmask of allowed sysrq functions | ||
+ | |} | ||
You can set the value in the file by the following command: | You can set the value in the file by the following command: | ||
Line 15: | Line 24: | ||
</pre> | </pre> | ||
− | To use SysRq feature you should press the key combo ' | + | == Available keys == |
+ | |||
+ | To use SysRq feature you should press the key combo 'Alt-SysRq-<command key>'. | ||
The 'SysRq' key is also known as the 'Print Screen' key. Other way, if you don't have | The 'SysRq' key is also known as the 'Print Screen' key. Other way, if you don't have | ||
physical access to the node, only ssh, you can do | physical access to the node, only ssh, you can do | ||
Line 24: | Line 35: | ||
Here is the list of most useful command keys: | Here is the list of most useful command keys: | ||
− | + | {| class="wikitable" | |
− | your disks | + | ! b |
− | + | | Will immediately re'''b'''oot the system without syncing or unmounting your disks | |
− | + | |- | |
− | + | ! s | |
− | + | | Will attempt to '''s'''ync all mounted filesystems | |
− | + | |- | |
− | + | ! u | |
− | + | | Will attempt to remo'''u'''nt all mounted filesystems read-only | |
− | will be printed to your console. ('0', for example would make | + | |- |
− | it so that only emergency messages like PANICs or OOPSes would | + | ! p |
− | make it to your console | + | | Will dum'''p''' the current registers and flags to your console |
− | + | |- | |
− | + | ! t | |
− | + | | Will dump a list of current '''t'''asks and their information to your console | |
− | <tt> | + | |- |
+ | ! m | ||
+ | | Will dump current '''m'''emory 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 SIGT'''E'''RM to all processes, except for init | ||
+ | |- | ||
+ | ! i | ||
+ | | Send a SIGK'''I'''LL to all processes, except for init | ||
+ | |- | ||
+ | ! h | ||
+ | | Will display '''h'''elp | ||
+ | |} | ||
+ | |||
+ | All output will appear on the console and/or in <tt>/var/log/messages</tt> file. | ||
− | + | == Example == | |
− | + | Suppose for some strange reason your system is working slow and you want to | |
ask developers what happens, then don't forget to press | ask developers what happens, then don't forget to press | ||
− | <tt> | + | <tt>Alt-SysRq-p</tt> and <tt>Alt-SysRq-t</tt> several times, |
and attach <tt>/var/log/messages</tt> to request. | and attach <tt>/var/log/messages</tt> to request. | ||
[[Category: Troubleshooting]] | [[Category: Troubleshooting]] | ||
+ | [[Category: Kernel]] |
Revision as of 10:42, 13 June 2006
Alt-SysRq-* 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.
/proc/sys/kernel/sysrq
When running a kernel with SysRq compiled in (as in all binary kernels released by OpenVZ),
/proc/sys/kernel/sysrq file controls the functions allowed to be invoked via the SysRq key.
Here is the list of possible values in /proc/sys/kernel/sysrq:
0 | disable sysrq completely |
---|---|
1 | enable all functions of sysrq |
>1 | bitmask of allowed sysrq functions |
You can set the value in the file by the following command:
echo "number" >/proc/sys/kernel/sysrq
Available keys
To use SysRq feature you should press the key combo 'Alt-SysRq-<command key>'. The 'SysRq' key is also known as the 'Print Screen' key. Other way, if you don't have physical access to the node, only ssh, you can do
echo "command key" > /proc/sysrq-trigger
Here is the list of most useful command keys:
b | Will immediately reboot the system without syncing or unmounting your disks |
---|---|
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 |
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 |
h | Will display help |
All output will appear on the console and/or in /var/log/messages file.
Example
Suppose for some strange reason your system is working slow and you want to ask developers what happens, then don't forget to press Alt-SysRq-p and Alt-SysRq-t several times, and attach /var/log/messages to request.