Linux Magic SysRq

by cw Email

The following comes with a warning: it may set fire to your cat, or cause your hair to fall out. YMMV.

Ok, this is handy to know. If you have some bad hardware or a bad install of linux, then you may occasionally get system lockups, g. where only the mouse moves, but nothing else works. Firstly, try CTRL-ALT-BKSPACE, this restarts the Xserver, the part responsible for giving you a user interface. If that doesn't work, bring out the big guns: The SYSRQ key. Now this key has been sitting idle in PC land for donkey's years, but the Linux Kernel developers put it to use as a wakeup call. Following details courtesy of Wikipedia:

Magic SysRq key

From Wikipedia, the free encyclopedia

Jump to: navigation, search

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

The key combination consists of Alt, SysRq and another key, which controls the command issued:

* 0 through 9 sets the console log level, which controls the types of kernel messages that are output to the console.

* b immediately reboots the system, without unmounting partitions or syncing.

* c reboots kexec and outputs a crashdump.

* e sends the SIGTERM signal to all processes except init (PID 1).

* f calls oom_kill, which will kill a process that is consuming all available memory.

* h, or any key which is not bound to a command, outputs a terse help document to the console.

* i sends the SIGKILL signal to all processes except init.

* k kills all processes on the current virtual console (and thus can be used to kill X and svgalib programs). This was originally designed to imitate a Secure Access Key.

* l sends the SIGKILL signal to all processes, including init.

* m outputs current memory information to the console.

* o shuts off the system.

* p outputs the current registers and flags to the console.

* r switches the keyboard from raw mode, the mode used by programs such as X11 and svgalib, to XLATE mode.

* s attempts to sync all mounted filesystems.

* t outputs a list of current tasks and their information to the console.

* u attempts to remount all mounted filesystems in read-only mode.

* v outputs Voyager SMP processor information.

If the machine is headless or is being accessed remotely, magic commands be run on the command line. This is, however, contingent upon being able to shell into the machine. To run magic commands, echo the desired trigger code to the SysRq trigger in the procfs. For example:

echo b > /proc/sysrq-trigger

This is equivalent to the key combination Alt + SysRq + B which reboots the machine.

The feature is controlled both by a compile-time option in the kernel configuration, CONFIG_MAGIC_SYSRQ, and a sysctl kernel parameter, kernel.sysrq. Some distributions only enable the compile-time option, while others, such as Ubuntu, enable the feature by default.



So, if in dire straits then use ALT-SYSRQ-K. This restarts the XServer. If still no go then ALT-SYSRQ-F, ALT-SYSRQ-S, wait a bit whilst the harddisk lights go, then ALT-SYSRQ-L, then ALT-SYSRQ-B.

Trackback address for this post

This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

Details

CombatWombat Speaks is a personal blog about Computing, Faith, and Life.
It is deliberately anonymous, as it doesn't really matter who I am.
What matters is the quality of the information within, and how
relevant it is to you.

There is a heavy emphasis here on technical computing, especially Linux, Ubuntu, Mint, Microsoft, VirtualBox, Networking, and Usability.

Please drop a comment in if you would like to have more details, or wish to learn about something specifically.

Close Details
CombatWombat speaks
2 Corinthians 10:4