Posted on 2010/02/18 15:39
Filed Under OS/redhat

출처 : http://kbase.redhat.com/faq/docs/DOC-2024


What is the SysRq facility and how do I use it?

Article ID: 2024 - Created on: May 9, 2005 6:00 PM - Last Modified: May 15, 2005 6:00 PM

What is the "Magic" SysRq key?


According to the Linux kernel documentation:


It is a 'magical' key combo you can hit which the kernel will respond to regardless of whatever else it is doing, unless it is completely locked up.


The sysrq key is one of the best (and sometimes the only) way to determine what a machine is really doing. It is useful when a system appears to be "hung" or for diagnosing elusive, transient, kernel-related problems.


How do I enable and disable the SysRq key?


For security reasons, Red Hat Enterprise Linux disables the SysRq key by default. To enable it, run:




# echo 1 > /proc/sys/kernel/sysrq


To disable it:




# echo 0 > /proc/sys/kernel/sysrq


To enable it permanently, set the kernel.sysrq value in /etc/sysctl.conf to 1. That will cause it to be enabled on reboot.




kernel.sysrq = 1


Since enabling sysrq gives someone with console access extra abilities, it is recommended to disable it when not troubleshooting a problem or to ensure that console access is properly secured.


How do I trigger a sysrq event?


There are several ways to trigger a sysrq event. On a normal system, with an AT keyboard, sysrq events can be triggered from the console with the following key combo:




Alt+PrintScreen+[CommandKey]


For instance, to tell the kernel to dump memory info (command key "m"), you would hold down the Alt and Print Screen keys, and then hit the m key.


Note that this will not work from an XWindows screen. You should first change to a text virtual terminal. Hit Ctrl+Alt+F1 to switch to the first virtual console prior to hitting the sysrq key combo.


On a serial console, you can achieve the same effect by sending a Breaksignal to the console and then hitting the command key within 5 seconds.


If you have a root shell on the machine (and the system is responding enough for you to do so), you can also write the command key character to the /proc/sysrq-trigger file. This is useful for triggering this info when you are not on the system console or for triggering it from scripts.




# echo 'm' > /proc/sysrq-trigger

When I trigger a sysrq event that generates output, where does it go?


When a sysrq command is triggered, the kernel will print out the information to the kernel ring buffer and to the system console. This information is normally logged via syslog to /var/log/messages.


Unfortunately, when dealing with machines that are extremely unresponsive, syslogd is often unable to log these events. In these situations, provisioning a serial console is often recommended for collecting the data.


What sort of sysrq events can be triggered?


There are several sysrq events that can be triggered once the sysrq facility is enabled. These vary somewhat between kernel versions, but there are a few that are commonly used:


  • m - dump information about memory allocation

  • t - dump thread state information

  • p - dump current CPU registers and flags

  • c - intentionally crash the system (useful for forcing a disk or netdump)

  • s - immediately sync all mounted filesystems

  • u - immediately remount all filesystems read-only

  • b - immediately reboot the machine

  • o - immediately power off the machine (if configured and supported)

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기
2010/02/18 15:39 2010/02/18 15:39

트랙백 주소 : http://blog.seabow.pe.kr/trackback/717



About

by 삐꾸강아쥐

Counter

· Total
: 137362
· Today
: 63
· Yesterday
: 0
블로그코리아에 블UP하기