Rebooting linux machine without disk access

This is a weird situation which I found myself in recently. One of the ubuntu servers were having issues and was unable to launch any process for unknown reason (kernel issue/disk or filesystem failure/etc). Puzzled, I tried to reboot the machine using shutdown and reboot, but the system did not allow me to. It also failed to run utilities such as ping, ifconfig, etc…

After some googling, here is the magic (“magic SysRq key”):

echo 1 >/proc/sys/kernel/sysrq
echo s > /proc/sysrq-trigger (optional, sync mounted filesystems)
echo u > /proc/sysrq-trigger (optional, remount filesystems as read-only)
echo b > /proc/sysrq-trigger

Aha! echo is a bash shell builtin command and does not have to be a new process. Reboot now!

Linux Magic System Request Key Hacks