[systemd-devel] How to keep certain services or mounts active during shutdown?
Frank Steiner
fsteiner-mail1 at bio.ifi.lmu.de
Fri Jul 3 03:14:54 PDT 2015
Hi,
Lennart Poettering wrote
>> 1. I want to keep the network running. To avoid problems with dependencies
>> I had to keep it enabled although all the stuff is done in the kernel/initrd.
>> Thus, it shuts down during reboot and the diskless client hangs
>> of course.
>
> This really depends on the network management service you are
> using. networkd won't shut down any network connections when you
> terminate it for example.
>
> Which one are you using?
it's "wicked" in SLES 12 and it really shuts the network interface down
(might be configuration issue, though). I managed to keep it up by a
drop-in conf with
ExecStop=
ExecStop=/usr/bin/true
(not sure if I need the second one, will check).
> Not sure if I grok why you want to do what you want to do (after all:
> if every user of your two NFS mounts are gone, why keep them around?),
Because we share / read-only with the server and mount only some
stuff (/var e.g.) for the client. To handle own runlevels we create
a tmpfs for /etc/systemd/system in dracut so the client can configure
its own runlevel dependencies.
The drop-in for avoiding the wicked shutdown is, of course, in this
tmpfs and could be unmounted before wicked tries to stop, thus, it
would fail to see the drop-in.
(This tmpfs was a NFS mount yesterday, that's why I wanted to keep it,
but we changed it to a tmpfs now).
> but you can do what you want by writing native .mount unit files for
> the file systems and the set DefaultDependencies=no. This will remove
> the implicit Conflicts= dependencies for shutdown.target. With those
> removed systemd won't try to unmount the mounts during the normal
> shutdown phase (unless there are mounts below them that are unmoutned, of
> course...).
That worked! I created a .mount file for the tmpfs with
DefaultDependencies=no
Before=network-online.target wicked.service
and so it was ordered after wicked during shutdown.
> Note though that there are actual two shutdown phases: the normal one
> that strictly follows unit dependencies, and which you can influence
> this way. And a final one, that then tries to clean-up everything that
> was left over by that first phase. It's basically a umount loop that
That's ok as I only need to keep the mounts over a certain point, then
they can go :-)
Thanks for your help!
cu,
Frank
--
Dipl.-Inform. Frank Steiner Web: http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17 Phone: +49 89 2180-4049
80333 Muenchen, Germany Fax: +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
More information about the systemd-devel
mailing list