--Drijen 15:06, 22 September 2007 (EDT)
Recovering from a System Lock
Sometimes a process can go out to lunch, or the system will simply stop responding to user input. This could be from a process waiting for resources or a zombie, but in any case there is no reason to have to reach for that reset button!
The Magic SysRq
The SysRq can be used as a means to save your work, sync the file system(s) and reboot the computer in a clean manner. If you don't know where the SysRq key is, look for the "Prt Scr" (Print Screen) button on your keyboard. SysRq is generally assigned to the same keypress.
Enabling the SysRq Function
To enable the SysRq functionality, you must have a 2.6.15 or higher kernel, and it must be compiled directly in. Not as a Module!
To check that you have it enabled you may run this command:
cat /boot/config |grep CONFIG_MAGIC_SYSRQ
zcat /proc/config.gz |grep SYSRQ
if you have /proc/.config support compiled in. (All base slack kernels do)
which should return:
If you find that you need to compile it in, the option can be found under the heading Kernel Hacking on your make <(x)(menu)config> screen.
Once you are satisfied that you have the SysRq funtion correctly compiled, ensure that it has not been disabled at boot:
If the response is 0 :
echo 1 > /proc/sys/kernel/sysrq
Recovering from a Lock Up using SysRq
If your system has gone out to lunch, you can now use the Magic SysRq key to save your work and reboot. The basic commands are as follows:
Alt+SysRq+R :Attempts to remove keyboard from Raw mode Alt+SysRq+E :Terminate request sent to all processes (SIGTERM / kill -15) Alt+SysRq+I :Kills all processes (SIGKILL / kill -9) Alt+SysRq+S :Syncs all disks Alt+SysRq+U :Force unmount and remount of all filesystems readonly Alt+SysRq+B :Reboots (INIT 6)
and roughly in that order. You should wait several seconds between each keystroke to let the system complete your request before you issue a new one.
There are several mnemonics to help you remember the key sequence:
Raising Elephants Is So Utterly Boring Reboot Even If System Utterly Broken BUSIER, spelt backwards
An alternative method is to:
This command will move the keyboard out of raw mode, and attempt to issue a SHUTDOWN NOW command. However, this will not work under some configurations, or if tty1 is defunct.
Further instructions and other options can be found at:
Wikipedia article on MagicSysRq