[systemd-devel] proper way to shutdown/reboot host with systemd

Vasiliy Tolstov v.tolstov at selfip.ru
Tue Aug 26 12:52:12 PDT 2014

2014-08-26 23:33 GMT+04:00 Lennart Poettering <lennart at poettering.net>:
> Hmm? What's "possible" supposed to mean? I mean, certainly you can
> invoke that syscall, and "systemctl reboot -ff" will do that for
> you. But I'd really recommend not ever doing that, unless your system is
> seriously stuck.
> In systemd, there are three ways to shut down the system:
> 1) The recommended way, by invoking PowerOff() on logind's manager
>    object. This will do polkit, respects inhibitors and
>    everything. Internally this then enqueues a start job for the
>    "poweroff.target"  unit in PID 1, which the shuts down the system
>    cleanly, and terminates all services in order. THis is accessible via
>    "systemctl poweroff".
> 2) The more agressive way, by invokign PowerOff() on PID1's
>    manager interface. This tells systemd to immediately go in the final
>    killing spree, without bothering with polkit, inhibitors or correctly
>    terminating all services in the right order. This is not nice to
>    system services and user applications, but will still unmount all the
>    file systems, detach loopback/DM/... and so on. This is accessible
>    via "systemctl poweroff -f". Also by sending SIGRTMIN+14 to PID 1.
> 3) The super-agressive way, by invoking the reboot() syscall
>    directly. This doesn't bother with unmounting, or anything else, it
>    just resets the machine. THis is accessible via "systemctl poweroff
>    -ff" (which however, does a sync() before, but nothing else, the
>    filesystem will be marked dirty on next reboot, you will get fsck
>    started, still).
> Usually there's no reason to ever use anything but #1.

Very good doc, what about  /sbin/shutdown  as i see it is wraps
systemctl shutdown, if i execute it with proper flags, for example
like shutdown -h -P +0 ?

Vasiliy Tolstov,
e-mail: v.tolstov at selfip.ru
jabber: vase at selfip.ru

More information about the systemd-devel mailing list