Monday, May 18, 2009

Fix a Frozen System with the Magic SysRq Keys

http://fosswire.com/post/2007/09/fix-a-frozen-system-with-the-magic-sysrq-keys/
It says:
You finally got your Linux environment to crash. Ctrl+Alt+Backspace does nothing [...]
The Linux kernel includes a secret method of restarting your PC should it ever stop doing its job.
  1. Hold down the Alt and SysRq (Print Screen) keys.
  2. While holding those down, type the following in order. Nothing will appear to happen until the last letter is pressed: REISUB
  3. Watch your computer reboot magically.
What the individual keys do in that sequence are not as important as
what it does as a whole: stops all programs, unmounts all drives, and
reboots. A lot safer than just cutting the power.

Here it is again: REISUB. Remember that, as it
will save you a lot of time when you are configuring a system and
something gets messed up. Need a mnemonic? Try Raising Elephants Is So Utterly Boring.


nix's note (09 Dec 2008):
Just some other additional notes: alt+print screen + REISUB = reboot alt+print screen + REISUO = shutdown

---------

See also:
http://en.wikipedia.org/wiki/Magic_SysRq_key:
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 under Gnome. It also can be accessed from the serial console
[...]
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.

This can prevent a fsck being required on reboot and gives some programs a chance to save emergency backups of unsaved work.

Another common version of this mnemonic device is "Raising Skinny Elephants Is Utterly Boring", which performs the same task, but in an alternate order. There is debate regarding whether the Sync command should come earlier or later.

Wait a few seconds between each command. For example, many applications will do an emergency save on receiving SIGTERM, but if SIGKILL is sent too soon, the application will not have time. Likewise, the Sync and Unmount processes need a few seconds before the system is rebooted.



No comments: