Sysrq: Difference between revisions

From Leo's Notes
This page was last edited on 1 September 2019, at 06:22.
m Text replacement - "Category:Linux" to "Category:Linux{{Navbox Linux}}"
m Text replacement - "Category:Linux{{Navbox Linux}}" to "{{Navbox Linux}}Category:Linux"
Line 27: Line 27:
* http://en.wikipedia.org/wiki/Magic_SysRq_key
* http://en.wikipedia.org/wiki/Magic_SysRq_key


[[Category:Linux]]{{Navbox Linux}}
{{Navbox Linux}}[[Category:Linux]]

Revision as of 06:22, 1 September 2019

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