Benutzer-Werkzeuge

Webseiten-Werkzeuge


sysreq

Reboot a locked Linux box with the Magic SysRq Keys

by Scott Morris @ 3:25 pm. Filed under How-To, General Linux

I ran across this rather informative Wikipedia page about something called the “Magic SysRq key.” It is a mechanism built into the kernel that allows you to reboot a machine without having to hold in the Power button. Because your disks don’t have a chance to sync, and other complications that can occur with such a shutdown, this is a great alternative. If your system becomes completely unresponsive, this is a forceful way to reboot the machine, but more graceful than the 6-second power button charade.

First, to see if your machine is set up to do this, run this command:

cat /proc/sys/kernel/sysrq

If you see a “0″, it is disabled. If you see a “1″, it is enabled.

To enable it, do this:

echo 1 > /proc/sys/kernel/sysrq

To disable it, do this:

echo 0 > /proc/sys/kernel/sysrq

Once you have it enabled, you can proceed to perform the operation.

To do this, you will need to hold down the ALT and SYSRQ (or PRINT SCREEN) buttons while typing the following key sequence:

(taken from wikipedia)

Alt + SysRq + R – takes the keyboard out of raw mode.

Alt + SysRq + E – terminates all processes (except init).

Alt + SysRq + I – kills all processes (except init).

Alt + SysRq + S – synchronizes the disk.

Alt + SysRq + U – remounts all filesystems read-only.

Alt + SysRq + B – reboots the machine.

One thing to keep in mind, however, is that you will want to give the machine time to complete each command, especially time between the last three commands. You want to make sure that the machine syncs the disk before remounting the filesystems, and you want to wait a moment to reboot the machine after it performs the remount.

sysreq.txt · Zuletzt geändert: 2008/10/23 22:00 (Externe Bearbeitung)