SysRq

From SlackWiki
Revision as of 23:31, 6 June 2009 by Erik (talk | contribs) (Copy from old)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

--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


OR

zcat /proc/config.gz |grep SYSRQ


if you have /proc/.config support compiled in. (All base slack kernels do)


which should return:


CONFIG_MAGIC_SYSRQ=y


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:


cat /proc/sys/kernel/sysrq


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+K :Kills all processes (SIGKILL / kill -9)
  Alt+SysRq+E :Terminates all processes (SIGTERM / kill -15)
  Alt+SysRq+I :Interrupts all processes (SIGINT / kill -2)
  Alt+SysRq+U :Force unmount and remount of all filesystems readonly
  Alt+SysRq+S :Syncs all disks
  Alt+SysRq+B :Reboots (INIT 6)


An alternative method is to:

Alt+SysRq+R CTRL+ALT+DEL

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.

Futher Information

Further instructions and other options can be found in:


/usr/src/<linux-version>/Documentation/sysrq.txt