Magic SysRq key

Magic SysRq key
The SysRq key

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 reboot a computer without corrupting the filesystem.[1][2]

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

Contents

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.

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 an '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 Screen" key should be present. Under graphical environments (such as Gnome or KDE) 'Alt'+'PrintScrn/SysRq'+key combination generally only leads to a screenshot being dumped. To avoid this Print Screen feature the magic SysRq combination should include the Ctrl, becoming 'Ctrl'+'Alt'+'SysRq'+key. For the same purposes the AltGr key, if present, can be used in place of the Alt key. On some laptops SysRq is accessible only by pressing 'Fn'. In this case the combination is a bit trickier: hold 'Alt', hold 'Fn', hold 'SysRq', release 'Fn', press key. The magic SysRq can also be accessed from the serial console.[3]

Action QWERTY Dvorak AZERTY
Set the console log level, which controls the types of kernel messages that are output to the console 0 through 9 0 through 9 0 through 9
(without using shift)
Immediately reboot the system, without unmounting partitions or syncing b x b
Reboot kexec and output a crashdump c j c
Display all currently held Locks d e d
Send the SIGTERM signal to all processes except init (PID 1) e . e
Call oom_kill, which kills a process to alleviate an OOM condition f u f
When using Kernel Mode Setting, provides emergency support for switching back to the kernel's framebuffer console[4] If the in-kernel debugger 'kdb' is present, enter the debugger. g i g
Output a terse help document to the console
Any key which is not bound to a command should also perform this action
h d h
Send the SIGKILL signal to all processes except init i c i
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 Secure Access Key
k t k
Output current memory information to the console m m ,
Reset the nice level of all high-priority and real-time tasks n b n
Shut off the system o r o
Output the current registers and flags to the console p l p
Display all active high-resolution timers and clock sources. q ' a
Switch the keyboard from raw mode, the mode used by programs such as X11 and svgalib, to XLATE mode r p r
Sync all mounted filesystems s o s
Output a list of current tasks and their information to the console t y t
Remount all mounted filesystems in read-only mode u g u
Output Voyager SMP processor information v k v
Display list of blocked (D state) tasks w , z

Feature configuration

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

Alternate ways to invoke Magic SysRq

Command line access

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.

Remote access over network

The linux daemon sysrqd provides a method of accessing SysRq features over TCP/IP port 4094 after authenticating with a plain-text password.

In hypervisors

The Xen hypervisor has functionality to send magic commands to hosted domains via its "xm sysrq" command.[5]

Over serial console

Many embedded systems have no attached keyboard, but instead use a serial console for text input/output to the running system. It is possible to invoke a Magic SysRq feature over a serial console by sending a 'break' serial command, followed by the desired key. The method of sending a break is dependent on the terminal program or hardware used to connect to the serial console.

For minicom, a popular serial terminal program, the command sequence: 'ctrl-a f' will initiate a break sequence. So the command: 'ctrl-a f m' would show memory information about the system.

Common Usage

“REISUB” – safe reboot

A common use of the magic SysRq key is to perform a safe reboot of a Linux computer which has otherwise locked up. This can prevent a fsck being required on reboot and gives some programs a chance to save emergency backups of unsaved work.[6] The QWERTY (or AZERTY) mnemonics: "Raising Elephants Is So Utterly Boring", "Reboot Even If System Utterly Broken" or simply the word "BUSIER" read backwards, are often used to remember the following Sysrq-keys sequence:

unRaw      (take control of keyboard back from X),
 tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
 kIll      (send SIGKILL to all processes, forcing them to terminate immediately),
  Sync     (flush data to disk),
  Unmount  (remount all filesystems read-only),
reBoot.
  1. Hold down the Alt and SysRq (Print Screen) keys.
  2. While holding those down, type the following in order, several seconds apart. Nothing will appear to happen until the last letter is pressed: REISUB
  3. Watch your computer reboot magically.

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.

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.

On distributions that do not include a textmode executable, the key command 'Ctrl'+'Alt'+'F1' may sometimes to force a return to a text console. (Use 'F1', 'F2', 'F3', ... , 'F(n)', where 'n' is the highest number of text consoles set up by the distribution. 'Ctrl'+'Alt'+ 'F(n+1)' would normally be used to reenter GUI mode on a system on which the X server has not crashed.)

Security concerns

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

On newer kernels (since 2.6.12[9]), it is possible to have a more fine-grained control.[10] On these machines, the number written to /proc/sys/kernel/sysrq can be zero, one, or a number greater than one which is a bitmask indicating which features to allow.

Possible values are:

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

See also

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Magic SysRq Key — Les magic SysRq key sont une fonctionnalité du noyau Linux qui permet par une combinaison de touches de lancer des commandes de bas niveau. Elle doit être activée à la compilation du noyau c est le cas d office sur la plupart des distributions.… …   Wikipédia en Français

  • Magic sysrq key — Les magic SysRq key sont une fonctionnalité du noyau Linux qui permet par une combinaison de touches de lancer des commandes de bas niveau. Elle doit être activée à la compilation du noyau c est le cas d office sur la plupart des distributions.… …   Wikipédia en Français

  • Magic SysRq key — Die Funktion „S Abf“ (engl. „SysRq“) ist auf IBM AT kompatiblen Tastaturen eine Alternativbelegung der „Druck“ Taste (engl. „Print Screen“) Als Magic SysRq Key (kurz für Magic Sysrequest key, engl.; Magische S Abf Taste ) wird eine Reihe von… …   Deutsch Wikipedia

  • Magic SysRq key — Les magic SysRq key sont une fonctionnalité du noyau Linux qui permet par une combinaison de touches de lancer des commandes de bas niveau. Elle doit être activée à la compilation du noyau c est le cas d office sur la plupart des distributions.… …   Wikipédia en Français

  • Magic SysRq — Die Funktion „S Abf“ (engl. „SysRq“) ist auf IBM AT kompatiblen Tastaturen eine Alternativbelegung der „Druck“ Taste (engl. „Print Screen“) Als Magic SysRq Key (kurz für Magic Sysrequest key, engl.; Magische S Abf Taste ) wird eine Reihe von… …   Deutsch Wikipedia

  • SysRq — Taste SysRq auf einer US 102 Tasten Tastatur rot eingekreist Die Funktion S Abf (Systemabfrage), auf Schweizer und US Tastaturen SysRq (System Request), ist ein Relikt von alten Terminal Tastaturen; dort bewirkt sie das Zurücksetzen der Tastatur… …   Deutsch Wikipedia

  • Secure Attention Key — Ctrl Alt Delete Cet article concerne la combinaison de touches Ctrl Alt Suppr. Voir également Ctrl+Alt+Del pour le webcomic. Control Alt Delete (souvent abrégé Ctrl Alt Del ou Ctrl Alt Suppr, Suppr étant la version française de la touche Del) est …   Wikipédia en Français

  • Secure attention key — Ctrl Alt Delete Cet article concerne la combinaison de touches Ctrl Alt Suppr. Voir également Ctrl+Alt+Del pour le webcomic. Control Alt Delete (souvent abrégé Ctrl Alt Del ou Ctrl Alt Suppr, Suppr étant la version française de la touche Del) est …   Wikipédia en Français

  • Magische S-Abf-Taste — Die Funktion „S Abf“ (engl. „SysRq“) ist auf IBM AT kompatiblen Tastaturen eine Alternativbelegung der „Druck“ Taste (engl. „Print Screen“) Als Magic SysRq Key (kurz für Magic Sysrequest key, engl. „Magische S Abf Taste“) wird eine Reihe von… …   Deutsch Wikipedia

  • System request — (often abbreviated SysRq or Sys Req) is a key on keyboards for PCs that has no standard usecite web|title=What is the SysRq key for?|work=comp.os.msdos.programmer FAQ|url=http://www.faqs.org/faqs/msdos programmer faq/part2/|accessdate=2008 01 08] …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”