[systemd-devel] How to keep certain services or mounts active during shutdown?

Mantas Mikulėnas grawity at gmail.com
Thu Jul 2 03:48:32 PDT 2015


On Thu, Jul 2, 2015 at 1:24 PM, Frank Steiner <fsteiner-mail1 at bio.ifi.lmu.de
> wrote:

> Hi,
>
> for our diskless clients I setup the network and the root fs in the
> kernel/initrd and do two additional mounts in the initrd which are
> specific for every client.
>
> I understand the boot concept with its dependencies and ordering but I've
> no idea how to influence the shutdown process in two ways:
>
> 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.
>
>    Changing the ExecStop to /usr/bin/true does work, but I wonder if there
>    is a better way in general to remove a process from the shutdown tree.
>    In SysV I just did "inserv -r network" in halt.local so that the
> shutdown
>    link was removed before it would be considered.
>
>    Is there something similar for systemd? "systemctl disable network"
>    didn't work.
>

No. Being an actual service manager, systemd keeps track _internally_ of
which services are active at any moment. Filesystem changes won't affect
that. (Messing around with service state was a bad idea in general, even
with sysvinit.)

If the 'main' network.service doesn't do anything anyway (since the network
is already up), you can replace it entirely with Type=oneshot,
ExecStart=/bin/true, RemainAfterExit=yes, essentially a service that does
nothing at all (but still satisfies dependencies).

(If you _actually_ meant "remove a process" instead of "remove a service",
then yes, there are some other methods, such as KillMethod= or the "@"
prefix [2]. But that isn't of much use for NFS, I think.)

2. The two additional NFS mounts should be kept active, too. There are no
>   *.mount files for them in /run/systemd/generator, because they are
>   mounted in the initrd I guess.
>

Not sure about this one. I wonder if the "shutdown initramfs" feature [1]
would help here.

[1]: http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface/
[2]: http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/

-- 
Mantas Mikulėnas <grawity at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150702/0869001b/attachment.html>


More information about the systemd-devel mailing list