📎 Webclip
Linux: emergency reboot or shutdown with magic commands
The post describes how most Linux distributions try to stop daemons and unmount storage cleanly during reboot or shutdown, but a badly behaving remote server can make a normal reboot impossible. In that situation, SysRq magic commands let you force a reboot or shut the machine down directly from /proc/sysrq-trigger.
Reading notes#
- Most Linux distributions use scripts to stop daemons and unmount storage volumes gracefully during reboot or shutdown.
- If a remote server is misbehaving, a plain
rebootcommand may fail before SSH stops running. - Writing
1to/proc/sys/kernel/sysrqenables SysRq access. echo b > /proc/sysrq-triggerforces an immediate reboot with no graceful shutdown, no filesystem sync, and possible filesystem damage.- The post mentions a safer reboot sequence from Wikipedia using the mnemonic “Reboot Even If System Utterly Broken”.
- The safer sequence is
unRaw,tErminate,kIll,Sync,Unmount,reBoot. - The author says they cannot vouch for that sequence actually working and adds an update warning that it is a very bad idea with ReiserFS.
echo o > /proc/sysrq-triggershuts the machine down entirely.- SysRq can be kept enabled all the time with
kernel.sysrq = 1insysctl.conf.
