If unmounting happens, deterministically, before shutdown, why not make your service WantedBy=umount.target (maybe still with DefaultDependencies=no)?
On Mon, Jan 21, 2013 at 4:38 AM, Umut Tezduyar <u...@tezduyar.com> wrote: > Hi > > How do I start a service on shutdown that will start and finish before any > of the mount points being unmounted? > > As it is explained here > (http://lists.freedesktop.org/archives/systemd-devel/2012-November/007558.html) > the shutdown order is the reverse of startup order though it is not clear > what is happening when a service that is not in the startup sequence is > being started. Following is a sample unit file I have been working on. > > [Unit] > Description=Taking Long Time > DefaultDependencies=no > Before=shutdown.target > > [Service] > Type=oneshot > ExecStart=/bin/sleep 60 > > [Install] > WantedBy=shutdown.target > > Before=shutdown.target ensures that shutdown.target is not reached before > the service is finished since it's type is "oneshot". But if I add > "Before=umount.target" or "Before=basic.target" to the service file, the > requested shutdown order is not obeyed. > > Output snipped: > > [OK] Stopped target Local File Systems > Unmounting /usr/local... > Unmounting /lib/persistent... > Starting Taking Long Time > [OK] Unmounted /usr/local > [OK] Unmounted /lib/persistent > > What am I trying to achieve: > > I would like to start a service on shutdown/restart. This service accesses > (read/write) to the file systems and for that reason I don't want any of the > file systems unmounted by systemd before the service completes. > > Thank you, > Umut > > > > _______________________________________________ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel > -- David Strauss | da...@davidstrauss.net | +1 512 577 5827 [mobile] _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel