Forced reboot on a linux system

I dont know how many of you manage Linux systems remotely but anyone who does will probably run into a situation where a reboot is the only way to fix things, usually when a disk has failed and will not unmount.
If you dont have iLO or Drac to remotely power cycle the system then its time to press the power switch. Not easy if the system is a hundred miles away and nobody is answering the phone.

There is a way round this by emulating the keyboard sequence used to force a reboot.

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

results in something like this

[root@emperor ~]# echo 1 > /proc/sys/kernel/sysrq
[root@emperor ~]# echo b > /proc/sysrq-trigger
Read from remote host Connection reset by peer
Connection to closed.

Before doing this its wise to ensure you have a working root password not just sudo access and that ssh restarts on boot.

Check ssh with

[root@emperor ~]# chkconfig --list sshd
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

This shows sshd will start at runlevels 2,3,4 and 5 and can be setup this way with the following command

# chkconfig --level 2345 sshd on

There are a lot of other features available through sysrq with full documentation available on RedHat for the curious.

Very interesting stuff :thumbsup:

Very cool :wink:

Sent from my X10i using Tapatalk