Is it possible to query systemd target?
martin.pitt at ubuntu.com
Wed Jan 13 16:55:20 UTC 2016
Stefan Bader [2016-01-13 16:10 +0100]:
> Is it possible to know from a script called via a systemd.service whether a stop
> action was manually triggered (systemctl) or as part of shutdown/reboot or poweroff?
This is a really slippery slope, and sounds like a big race condition.
IMHO, if someone or something stops a unit, it should stop. But we can
arrange for a unit to not get stopped during shutdown, which is IMO a
cleaner approach to this problem.
> Right now (at least Wily+Xenial) there is a non fatal but annoying problem with
> Xen. On shutdown/reboot systemd tries to unmount several file systems. One of
> which is /proc/xen. Right now Xen still uses /etc/init.d/xen for start/stop. The
> same script is also called via invoke-rc.d from *.prerm/*.postinst (which might
> be another place to modernize at some point). And because of that there is one
> daemon (xenstored) that must be kept running on stop (otherwise state info on
> guests running during the upgrade is lost).
I'm a bit lost here -- what does the xen init.d script have to do with
cleaning up mounts during shutdown? When you say "systemd tries to
unmount several file systems", that's happening very late after every
service has stopped and it basically does the equivalent of "umount -a",
right? (This is "umount.target", see man systemd.special.)
Or do you mean that the xen init script does the umount, but
has some heuristics to know whether it's during shutdown or during a
> And since xenstored keeps the /proc/xen mount busy there is always a
> failed unmount on shutdown/reboot. Harmless but not pretty. So I
> wondered whether I might be able to improve this for Xenial.
This should be possible to do with providing an explicit (instead of
autogenerated) /lib/systemd/system/proc-xen.mount unit which does not
do the default "Conflicts=umount.target". This should then keep the
mount alive all the time. I'll try this tomorrow morning (sorry, need
to run now). But let's first clarify what you need here.
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: Digital signature
More information about the ubuntu-devel