Linux kernel Magic SysRq Key

Kernel Panic了就有用了

The magic SysRq key is a key combination in the Linux kernel which allows the user to perform various low level commands regardless of the system’s state.

通常用来从僵死的系统中恢复,或者在不上海文件系统的情况下重启,键盘组合是

Alt+SysRq+命令

临时打开Magic SysRq Key支持

echo 1 > /proc/sys/kernel/sysrq
或者
sysctl -w kernel.sysrq=1

永久打开需要修改sysctl设置

kernel.sysrq=1

列表:

k Kills all the process running on the current virtual console
s 同步所有已经挂载的文件系统.
n Reset the nice level of all high-priority and real-time tasks
d Display all currently held Locks
c Reboot kexec and output a crashdump
g When using Kernel Mode Setting, provides emergency support for switching back to the kernel's framebuffer console
b 立即重启系统,不卸载分区和同步文件.
e 给除了init以外的所有进程发送SIGTERM信号,可以试图正常结束所有进程。
i Send the SIGKILL signal to all processes except init
m Output current memory information to the console.
r 转换keyboard 到 XLATE mode.(摆脱X的控制)
t Output a list of current tasks and their information to the console.
u 以只读模式重新挂载所有已经挂载的文件系统
o 可能的话,关机。
p Print the current registers and flags to the console.
q Display all active high-resolution timers and clock sources.
0-9 设置终端日志级别
v Output Voyager SMP processor information
w Display list of blocked (D state) tasks
f 调用oom_kill函数来干掉占用很大内存的进程。
h 显示帮助(其他未定义的按键也会显示帮助)

也可以把这些键值发送到/proc/sysrq-trigger生效设置。
例如

echo b > /proc/sysrq-trigger


Magic SysRq Key最有名的busier(倒过来)组合

unRaw (take control of keyboard back from X11,)
tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
kIll (send SIGILL to all processes, forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
reBoot.

Author Info :
  • From:Linux kernel Magic SysRq Key
  • URL:https://blog.ihipop.com/2010/11/1879.html
  • Please Reserve This Link,Thanks!
  • 发表回复

    您的电子邮箱地址不会被公开。 必填项已用 * 标注