↓ Ir para o conteúdo principal

← todas as notas

📎 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 reboot command may fail before SSH stops running.
  • Writing 1 to /proc/sys/kernel/sysrq enables SysRq access.
  • echo b > /proc/sysrq-trigger forces 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-trigger shuts the machine down entirely.
  • SysRq can be kept enabled all the time with kernel.sysrq = 1 in sysctl.conf.