Wednesday, January 5, 2011

Magic SysRq Key

I'll be honest, I've been a Linux user for almost 10 years now and when someone asked me about the "Magic SysRq Key" (ALT+SYSRQ+<another key>) I was stumped.  In all my years as an Enterprise Linux Support, I'd never come across it before.

Basically, the "Magic SysRq Key" is a key combination that the Linux Kernel will respond to, no matter the state of the system.  This came up recently, when an old decrepit RHEL2.1AS system failed to respond after its schedule monthly reboot.  We're a fairly small IT shop and don't have any iLO, DRAC or RSA cards (or even a BladeCenter) installed in our systems for hardware management of our devices.  The system was in a hung state and had shutdown all services, consoles, etc, but was stuck on a java process.  We have an IP KVM so we were able to see the system's state, but unable to action it.


Ultimately, a site visit was required and a quick hard reset brought the system back up.  However, had we'd known about the "Magic SysRq Key", we may have been able to avoid a trip to the office.


According to Wikipedia (the God of all IT -- of course) the following options are available:

ActionQWERTYDvorakAZERTY
Set the console log level, which controls the types of kernel messages that are output to the console0 through 90 through 90 through 9
(without using shift)
Immediately reboot the system, without unmounting partitions or syncingbxb
Reboot kexec and output a crashdumpcjc
Display all currently held Locksded
Send the SIGTERM signal to all processes except init (PID 1)e.e
Call oom_kill, which kills a process to alleviate an OOM conditionfuf
When using Kernel Mode Setting, provides emergency support for switching back to the kernel's framebuffer console[3]gig
Output a terse help document to the console
Any key which is not bound to a command should also perform this action
hdh
Send the SIGKILL signal to all processes except initici
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
ktk
Output current memory information to the consolemm,
Reset the nice level of all high-priority and real-time tasksnbn
Shut off the systemoro
Output the current registers and flags to the consoleplp
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 moderpr
Sync all mounted filesystemssos
Output a list of current tasks and their information to the consoletyt
Remount all mounted filesystems in read-only modeugu
Output Voyager SMP processor informationvkv
Display list of blocked (D state) tasksw,z
However a handy mnemonic is "Reboot Even If System Utterly Broken" will help you gracefully (as possible -- the system is in a state where you're resorting to this) reboot.  Next time, give it a try!

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.

No comments:

Post a Comment