9

I tried rebooting my CentOS 7 server but it gives ridiculous error messages.

As root (of course):

# systemctl reboot
Authorization not available. Check if polkit service is running or see debug message for more information.
Failed to start reboot.target: Connection timed out
See system logs and 'systemctl status reboot.target' for details.
Exit 1

Does polkit need to check whether root has the right to reboot the machine??? If so, why?

# systemctl status reboot.target
● reboot.target - Reboot
   Loaded: loaded (/usr/lib/systemd/system/reboot.target; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd.special(7)
Exit 3

Do I need to enable the reboot target? Why would this be disabled by default?

Perhaps this will work?

# systemctl start reboot.target
Authorization not available. Check if polkit service is running or see debug message for more information.
Failed to start reboot.target: Connection timed out
See system logs and 'systemctl status reboot.target' for details.
Exit 1

OK, force it, then:

# systemctl --force reboot
Authorization not available. Check if polkit service is running or see debug message for more information.
Failed to execute operation: Connection timed out
Exit 1

And the server is still up.

Ned64
  • 8,486
  • 9
  • 48
  • 86

3 Answers3

13

If Zach Sanchez' answer doesn't work (I got Failed to start reboot.target: Connection timed out for my systemctl --force reboot in a strange situation under CentOS 7) making the kernel basically crash reboot can be done over SSH as root like this:

# echo s > /proc/sysrq-trigger
# echo u > /proc/sysrq-trigger
# echo b > /proc/sysrq-trigger

After the last command, no response is excepted as the kernel immediately reboots the machine. More details here

As @LunarShaddow and others pointed out, a second "s" before "b" is not needed.

Paul
  • 231
  • 2
  • 3
  • Thanks for that, good idea! Zach's answer does do the job for me, though. – Ned64 Apr 07 '20 at 16:18
  • As @LunarShaddow points out, the second `s` is not necessary. Of course, it cannot hurt either, especially since it costs only 3 key presses. They give this as a reference: [https://www.kernel.org/doc/html/v4.10/admin-guide/sysrq.html]. – Ned64 May 09 '20 at 12:01
  • `reboot -f` will also do the job. – schemacs Sep 24 '21 at 07:45
  • The docs for `reboot -f` say that "When specified twice, this results in an immediate shutdown without contacting the system manager. See the description of --force in systemctl(1) for more details.". So in dire situations, you might want to try `reboot -f -f`. – Paul Sep 26 '21 at 09:56
8

As weird as it may seem, trying running

sudo systemctl --force reboot

It has popped up in a couple of searches I made. It may be related to issues with a DBus service restarting.

Can't reboot. Slow and timing out. Failed to start reboot.target: Connection timed out

Paulo Tomé
  • 3,754
  • 6
  • 26
  • 38
Zach Sanchez
  • 304
  • 1
  • 5
  • Thanks, I will try this but meanwhile started a long task and need to wait for it to complete before testing your solution - will get back to you. – Ned64 Aug 07 '19 at 09:49
  • 1
    I'm curious - can you explain how/why `sudo systemctl --force reboot` should work when running `systemctl --force reboot` _as root_ does not? Fascinating! – roaima May 07 '20 at 17:25
  • Today one thing that worked is in fact `systemctl --force --force reboot` when `systemctl --force reboot` did not. – Ned64 Sep 28 '21 at 19:43
1

Since I cannot make comments in Paul's answer, I write my comments here.

From the kernel document:

reboot(b) is good when you’re unable to shut down. But you should also sync(s) and umount(u) first. reboot(b) is good when you’re unable to shut down. But you should also sync(s) and umount(u) first.

sync(s) is great when your system is locked up, it allows you to sync your disks and will certainly lessen the chance of data loss and fscking. Note that the sync hasn’t taken place until you see the “OK” and “Done” appear on the screen. (If the kernel is really in strife, you may not ever get the OK or Done message...)

umount(u) is basically useful in the same ways as sync(s). I generally sync(s), umount(u), then reboot(b) when my system locks. It’s saved me many a fsck. Again, the unmount (remount read-only) hasn’t taken place until you see the “OK” and “Done” message appear on the screen.

So FMHO, Paul's answer can be simplified to 's' 'u' 'b', and you might want to wait for a while after each input.