[systemd-devel] proper way to shutdown/reboot host with systemd
Lennart Poettering
lennart at poettering.net
Tue Aug 26 12:58:28 PDT 2014
On Tue, 26.08.14 23:52, Vasiliy Tolstov (v.tolstov at selfip.ru) wrote:
>
> 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 ?
We support /usr/sbin/shutdown only for compat reasons...
If you use it with a time spec of "now", then this is just an alias for
"systemctl poweroff". If you use it with another time spec, then it will
tell this to a "shutdownd" daemon running in the background, that will
wait for the time to elapse, and then invoke the original tool again,
but this time with a time spec of "now"...
We probably should add a proper scheme for timed shutdowns to logind,
and get rid of shutdownd...
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list