Shami's Blog

Sysadmin, Because Even Developers Need Heroes

Simulate Pressing the Reset Button

2021-06-03

We’ve all been there, something gets stuck and there is no way to fix it except for a reboot, but even rebooting through SSH isn’t working and you don’t have physical access to the server or an out-of-bound way to power cycle. This has mostly bit me while working on NFS but there has been other cases. Adding it here for reference.

Disclaimer

Doing this might result in data loss. The commands below cause an instant power cycle similar to pressing the reset switch or unplugging/replugging the power cord. Any dirty buffers will not be saved to disk. Do not use unless you absolutely have to and know what you are doing.

For FreeBSD:

sysctl debug.kdb.panic=1

For Linux:

echo b > /proc/sysrq-trigger

# Some documentation mentions you need to enable sysrq first, but it was never the case for me
# Adding it here for reference
echo 1 > /proc/sys/kernel/sysrq

About Me

Dev gone Ops gone DevOps. Any views expressed on this blog are mine alone and do not necessarily reflect the views of my employer.

twitter linkedin