Você está na página 1de 6

Magic SysRq key - Wikipedia, the free encyclopedia

http://en.wikipedia.org/w/index.php?title=Magic_S...

Magic SysRq key


From Wikipedia, the free encyclopedia

The magic SysRq key is a key combination understood by the Linux kernel, which allows the user to perform various low level commands regardless of the system's state. It is often used to recover from freezes, or to [1] reboot a computer without corrupting the filesystem.

The SysRq key

To be able to use this functionality the CONFIG_MAGIC_SYSRQ option has to be enabled at kernel compile time.

Contents
1 Purpose 2 Magic commands 3 Common usage 3.1 Command line access and configuration 3.2 Remote access 3.3 Graphical programs 3.4 In hypervisors 4 "Raising Elephants" mnemonic device 5 Security concerns 5.1 Disabling SysRq key 6 See also 7 References 8 External links

Purpose
Much like Sun Microsystems's Open Firmware (OpenBoot), this key combination provides access to powerful tools for software development and disaster recovery. In this sense, it can be considered a form of escape sequence. Principal among the offered commands are means to forcibly unmount file systems, kill processes, recover keyboard state, and write unwritten data to disk. With respect to these tasks, this feature serves as a tool of last resort.

1 de 6

16-01-2010 17:39

Magic SysRq key - Wikipedia, the free encyclopedia

http://en.wikipedia.org/w/index.php?title=Magic_S...

Magic commands
The key combination consists of Alt, SysRq and another key, which controls the command issued (as shown in the table below). Users with a keyboard layout other than QWERTY have to remember that their layout becomes QWERTY when they use one of these combinations. For example, on a Dvorak keyboard, the key below '9' and '0' counts as a 'o', not as an 'r', so it shuts the system down instead of switching the keyboard to raw mode. Furthermore, some keyboards may not provide a separate SysRq key. In this case, a separate "Print" key should be present. The AltGr key, if present, can be used in place of Alt key in order to avoid alternative uses of these combinations such as Screenshot for Alt+SysRq+s [2] under Gnome. It also can be accessed from the serial console. Action QWERTY Dvorak AZERTY 0 through 9 (without using shift) b c d e f

Set the console log level, which controls the 0 0 through types of kernel messages that are output to through 9 the console 9 Immediately reboot the system, without unmounting partitions or syncing Reboot kexec and output a crashdump Display all currently held Locks Send the SIGTERM signal to all processes except init (PID 1) Call oom_kill, which kills a process to alleviate an OOM condition When using Kernel Mode Setting, provides emergency support for switching back to [3] the kernel's framebuffer console Output a terse help document to the console Any key which is not bound to a command should also do the trick Send the SIGKILL signal to all processes except init Kill all processes on the current virtual console (Can be used to kill X and svgalib programs, see below) This was originally designed to imitate a b c d e f x j e . u

2 de 6

16-01-2010 17:39

Magic SysRq key - Wikipedia, the free encyclopedia

http://en.wikipedia.org/w/index.php?title=Magic_S...

Secure Access Key Show a stack backtrace of all currently executing tasks Output current memory information to the console Reset the nice level of all high-priority and real-time tasks Shut off the system Output the current registers and flags to the console l m n o p n m b r l ' p o y g k , l , n o p a r s t u v z

Display all active high-resolution timers and q clock sources. Switch the keyboard from raw mode, the mode used by programs such as X11 and svgalib, to XLATE mode Sync all mounted filesystems Output a list of current tasks and their information to the console Remount all mounted filesystems in read-only mode Display list of blocked (D state) tasks r s t u

Output Voyager SMP processor information v w

Common usage
Command line access and configuration
While this was originally implemented as part of the kernel's keyboard handler for debugging, the functionality has been also exposed via the proc filesystem and is commonly used to provide extended management capabilities to headless and remote systems. As an example, shell script can be simply used: echo b > /proc/sysrq-trigger This is equivalent to the key combination Alt + SysRq + B which reboots the machine.
3 de 6 16-01-2010 17:39

Magic SysRq key - Wikipedia, the free encyclopedia

http://en.wikipedia.org/w/index.php?title=Magic_S...

The feature is controlled both by a compile-time option in the kernel configuration, CONFIG_MAGIC_SYSRQ, and a sysctl kernel parameter, kernel.sysrq.

Remote access
The linux daemon sysrqd (http://julien.danjou.info/sysrqd/) provides a method of accessing SysRq features over TCP/IP port 4094 after authenticating with a plain-text password.

Graphical programs
When magic SysRq keys are used to kill a frozen graphical program, the program has no chance to restore text mode. This can make everything unreadable. The commands textmode (part of SVGAlib) and reset can restore text mode and make the console readable again.

In hypervisors
The Xen hypervisor has functionality to send magic commands to hosted domains [4] via its "xm" command.

"Raising Elephants" mnemonic device


A common idiom to perform a safe reboot of a Linux computer which has otherwise locked up, the QWERTY (or AZERTY) mnemonic "Raising Elephants Is So Utterly Boring", "Reboot Even If System Utterly Broken" or simply [5] It stands for remembering the word "BUSIER" backwards, is often useful.
unRaw tErminate kIll Sync Unmount reBoot. (take control of keyboard back from X), (send SIGTERM to all processes, allowing them to terminate gracefully), (send SIGKILL to all processes, forcing them to terminate immediately), (flush data to disk), (remount all filesystems read-only),

This can prevent a fsck being required on reboot and gives some programs a chance to save emergency backups of unsaved work. In practice, each command may require a few seconds to complete, especially if feedback is unavailable from the screen due to a freeze or display corruption. For example, sending SIGKILL to processes which have not yet finished terminating can cause data loss.

4 de 6

16-01-2010 17:39

Magic SysRq key - Wikipedia, the free encyclopedia

http://en.wikipedia.org/w/index.php?title=Magic_S...

Security concerns
Some people view this key as giving access to dangerous system-level commands [6] It has to anyone who has physical access to the keyboard or serial console. been argued that this perceived security is illusory, as anyone with physical access to the computer would already have the capability to compromise its [7] The advent of the procfs interface has rekindled debate over this security. subject.

Disabling SysRq key


The SysRq key can be disabled with the following command:
echo 0 > /proc/sys/kernel/sysrq

To re-enable:
echo 1 > /proc/sys/kernel/sysrq

See also
Console server KVM switch Power distribution unit System console

References
1. ^ Linux Magic System Request Key Hacks (http://lxr.linux.no/linux/Documentation /sysrq.txt) 2. ^ Remote Serial Console HOWTO by Glen Turner (http://www.tldp.org/HOWTO /Remote-Serial-Console-HOWTO/index.html) 3. ^ DRM: i915: add mode setting support (http://git.kernel.org/?p=linux/kernel /git/torvalds/linux-2.6.git;a=commit; h=79e539453b34e35f39299a899d263b0a1f1670bd) 4. ^ Red Hat Virtualization Guide Section 22.2. The xm command line interface (http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.2/html/Virtualization /sect-Virtualization-Commands_for_Red_Hat_VirtualizationThe_xm_command_line_interface.html) 5. ^ Fix a Frozen System with the Magic SysRq Keys by Jacob Peddicord (http://fosswire.com/2007/09/08/fix-a-frozen-system-with-the-magic-sysrq-keys/) 6. ^ "SysRq: The Process-nuke" By Vikas G P at linuxgazette.net (http://linuxgazette.net

5 de 6

16-01-2010 17:39

Magic SysRq key - Wikipedia, the free encyclopedia

http://en.wikipedia.org/w/index.php?title=Magic_S...

/issue81/vikas.html) 7. ^ The Linux-Kernel Archive "Re: Speaking of SysRQ..." by Mike A. Harris (http://lkml.indiana.edu/hypermail/linux/kernel/9806.1/0737.html) Tony Lawrence (April 13, 2005). "General notes on magic sysrq" (http://aplawrence.com/Words2005/2005_04_13.html) . A.P. Lawrence website. http://aplawrence.com/Words2005/2005_04_13.html. Tom Gall (April 1, 2000). "Magic sys request" (http://web.archive.org /web/20070527215139/http://www.ibm.com/developerworks/linux/library /l-magic.html) . Linux. IBM Developer Works. Archived from the original (http://www.ibm.com/developerworks/linux/library/l-magic.html) on May 27, 2007. http://web.archive.org/web/20070527215139/http://www.ibm.com/developerworks /linux/library/l-magic.html.

External links
Documentation/sysrq.txt (http://www.kernel.org/doc/Documentation /sysrq.txt) in the Linux kernel source tree Kernel patch to the -mm tree that added the /proc/sysrq-trigger feature (http://kernel.org/pub/linux/kernel/people/akpm/patches/2.5/2.5.64/2.5.64mm7/broken-out/proc-sysrq-trigger.patch) This makes sysrq facilities available to remote users. Retrieved from "http://en.wikipedia.org/wiki/Magic_SysRq_key" Categories: Mnemonics | Linux kernel features | System administration | Out-of-band management This page was last modified on 16 January 2010 at 19:04. Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. See Terms of Use for details. Wikipedia is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization. Contact us

6 de 6

16-01-2010 17:39

Você também pode gostar