I'm constantly surprised when I come across long-time Linux users who don't know about SysRq. The Linux Magic System Request Key Hacks are a magic set of commands that you can get the Linux kernel to follow no matter what's going on (unless it has panicked or totally deadlocked).
Why is this useful? Well, there are many situations where you can't shut a system down properly, but you need to reboot. Examples:
- You've had a kernel OOPS, which is not quite a panic but there could be memory corruption in the kernel, things are getting pretty weird, and quite honestly you don't want to be running in that condition for any longer than necessary.
- You have reason to believe it won't be able to shut down properly.
- Your system is almost-locked-up (i.e. the above point)
- Your UPS has about 10 seconds worth of power left
- Something is on fire (
- ...Insert other esoteric failure modes here...
In any of those situations, grab a console keyboard, and type Alt+SysRq+s (sync), Alt+SysRq+u (unmount), wait for it to have synced, and finally Alt+SysRq+b (reboot NOW!). If you don't have a handy keyboard attached to said machine, or are on another continent, you can
# echo u > /proc/sysrq-trigger
In my books, the useful SysRq commands are:
- Call the oom_killer
- Display SysRq help
- Print a kernel stacktrace
- Power Off
- Set your keyboard to RAW mode (required after some X breakages)
- Sync all filesystems
- Remount all filesystems read-only
- Change console logging level
In fact, read the rest of the SysRq documentation, print it out, and tape it above your bed. Next time you reach for the reset switch on a Linux box, stop your self, type the S,U,B sequence, and watch your system come up as if nothing untoward has happened.
Update: I previously recommended U,S,B but after a bit of digging, I think S,U,B may be correct.