Ever encoutered a frozen X-Server without the possibility to switch to another console or a rare, but nasty kernel panic? Probably and I guess the majority of the people hit the power button in those cases risking data loss.
This is not necessary. There are other ways to restart a frozen Linux system!
The kernel has a feature called “Magic System Request Keys” – if it was compiled with the CONFIG_MAGIC_SYSRQ option though. It is available via ALT+PRINT on most systems and provides various low level commands to safely turn of or reboot your computer in case of a failure.
If you want to know whether this feature is available on your machine, ask /proc for it. If it returns a 1 Magic SysRq is active, a 0 indicates that it’s not.
user@server:~$ cat /proc/sys/kernel/sysrq 1
Hold down ALT+PRINT and type slowly REISUB to restart your system. Hold down ALT+PRINT and type REISUO to turn it off.
A short note on what REISUB or REISUO does:
- R – Switches the keyboard from raw to XLATE mode (detatching from the X-Server)
- E – Sending a SIGTERM to all processes except INIT
- I – Sending a SIGKILL to all processes except INIT (and that’s why to type REISUB slowly)
- S – Syncs all data in the cache to mounted partitions
- U – Unmounts all mounted partitions and remounts them read-only
- B – Reboot the system immediately without unmounting or syncing mounted partitions
or
O – Shut down the system immediately without unmounting or syncing mounted partitions
Be aware of the fact that the feature is currently broken in Ubuntu 8.10 because of a problem regarding kbd, evdev and 8.10′s xserver version. It only works from a text console, therefore not on the X-Server.
It is possible to reconfigure the xorg.conf from kbd to evdev like in the following, but no guarantees:
Section "InputDevice" Identifier "Generic Keyboard" Driver "kbd" Option "XkbRules" "xorg" Option "XkbModel" "pc105" Option "XkbLayout" "de" EndSection
Section "ServerLayout" ... InputDevice "Generic Keyboard" Option "AutoAddDevices" "false" EndSection
It’ll be fixed in 9.04 coming this April as stated in the bug description on Launchpad.
One last hint: If your machine doesn’t have a PRINT/SysRq key and you’re still able to access the console, yu may also send the commands via echo to the sysrq-trigger as seen in the example below:
user@server:~$ echo r | sudo tee /proc/sysrq-trigger
Add your comment below, or trackback from your own site.
Subscribe to these comments.
Be nice. Keep it clean. Stay on topic. No spam.
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">