Skip to main content

How to force a Linux server to restart?

Occasionally, some devices are locked, multiple disk mountings are lost, or the processes are stuck and the server responds very slowly. In such cases, the easiest solution is to restart the server.

For example, if one of the devices is locked or a mount point is damaged, the server cannot be restarted in the normal way.

Attention! The following command is not safe to use, so use it only in very justified cases! Adding a command can damage the file system and cause data loss.

After connecting to the server via SSH, you can force restart by issuing the following command:

echo 1 > /proc/sys/kernel/sysrq && echo b > /proc/sysrq-trigger

Attention! You cannot undo the release of this command!

The above command allows sysrq to be used. This allows us to communicate directly with the kernel. The second step sends the trigger b (to restart) to sysrq, which forces a restart.

The system will restart within a few minutes approximately as if the reset button was pressed on the machine. After restarting the system, you will be able to find and fix the problem.