[systemd-devel] Problems running services on system shutdown before umount
Mads Kiilerich
mads at kiilerich.com
Tue Nov 29 09:29:50 PST 2011
I would like to write to a log file on a local file system on system
shutdown (or just before).
I have problems getting that right. It seems like the file systems often
get unmounted before my service is executed. I guess it is the special
umount.target that is umounting?
poweroff.service (and reboot) has
Requires=shutdown.target umount.target final.target
and final.target has
After=shutdown.target umount.target
A oneshot service referenced in shutdown.target.wants works, but when it
is invoked the filesystems has already been unmounted and I can't do much.
The service works correctly if I remove the requirement for
umount.target from the poweroff service(s) with this ugly hack:
sed -i 's,umount.target,,g' /lib/systemd/system/*.service
- which confirms that it really is the umount target that triggers the
unmounting.
But adding
Before=umount.target
to my service makes no difference.
Is umount.target special in this regard? Or is it just that
umount.target already has been started in parallel with shutdown.target?
If so: is it really intended that shutdown.target and umount.target
should run in parallel without any synchronization?
If I instead reference my service in umount.target.wants then it is not
invoked.
Is umount.target special in this regard? Is it not possible to hook
anything on to it?
Looking at other services running at shutdown I don't see any tricks
that seems to ensure that it is run before umount.
Can you give a hint to help me understand what is going on and how to
get it right?
I'm using systemd-37-3.fc16.
/Mads
More information about the systemd-devel
mailing list