Sysrq
The magic SysRq key provides a way to instruct the kernel through the /proc
pseudo-filesystem. It must be enabled with the kernel during compile time with the CONFIG_MAGIC_SYSRQ
option and is standard for most distributions.
Rebooting
Suppose you have a system that you can SSH into but cannot reboot because the system disk is dying or the SATA bus is in some weird state and no IO is actually working.
# reboot
bash: /sbin/reboot: Input/output error
# shutdown -r now
bash: /sbin/shutdown: Input/output error
Or perhaps the system disk is fine, but sync()
isn't returning which causes reboot
to hang even with the -f
option.
To reboot the machine in such a state, enable sysrq and write 'b' to the sysrq-trigger.
## Enable sysrq
# echo 1 > /proc/sys/kernel/sysrq
## Reboot the machine without sync immediately
# echo b > /proc/sysrq-trigger
See Also
- https://www.mjmwired.net/kernel/Documentation/sysrq.txt
- http://en.wikipedia.org/wiki/Magic_SysRq_key