[systemd-devel] Should automount units for network filesystems be Before=local-fs.target?

Michael Chapman mike at very.puzzling.org
Sat Apr 29 12:04:12 UTC 2017


On Sat, 29 Apr 2017, Lennart Poettering wrote:
> On Thu, 27.04.17 15:53, Michael Chapman (mike at very.puzzling.org) wrote:
>
>> Hello all,
>>
>> At present, when systemd-fstab-generator creates an automount unit for an
>> fstab entry, it applies the dependencies that would have been put into the
>> mount unit into the automount unit instead.
>>
>> For a local filesystem, this automount unit would be Before=local-fs.target.
>> For a network filesystem, it gets Before=remote-fs.target. If the mount is
>> not noauto, it also gets a corresponding WantedBy= or RequiredBy=
>> dependency.
>>
>> Would it make more sense for the automount unit to be ordered before (and,
>> if not noauto, be pulled in by) local-fs.target, even for network
>> filesystems?
>
> We can't really do that in the generic case, sorry. The distinction
> between local-fs.target and remote-fs.target mostly exists because the
> latter may rely on network management services which aren't available
> in early boot. Spefically, NetworkManager traditionally runs during
> late boot, not during early boot. Now, if we'd permit that an autofs
> mount is already established in early boot but can only be fulfilled
> in late boot, then we'd open the doors to a variety of deadlocks
> triggered by early-boot services accessing these mounts at a point in
> time where the backing mounts cannot be established yet.

That would imply these early boot services accessing paths that are going 
to be over-mounted by the network filesystem later on... which is a tad 
strange, but admittedly quite possible.

> You can do what you want locally though if you are reasonably sure
> that such a deadlock cannot be triggered (for example, because you
> know that your networking management solution already runs in early
> boot). One way to do this is by adding
> "x-systemd.before=local-fs.target" as mount option to the relevant
> mounts in fstab. (note though that x-systemd.before= is a relatively
> recent addition to systemd though)
>
> Lennart

Yeah, I don't really want to pull the whole .mount in early too, since I 
am relying on normal late-boot configuration of the network.

I'm going to have to just add After=remote-fs.target drop-ins for a whole 
_lot_ of services that could _possibly_ access data on network 
filesystems. Unfortunately I don't really have control over what these 
services do, and I don't necessarily know which ones will actually need 
the network filesystems, so I'm going to just have to punt and add the 
drop-in on them all.

It's a pity that After=remote-fs.target isn't in a service's default 
dependencies (obviously, services that set up networking would then need 
DefaultDependencies=no, but there's far fewer of those). People generally 
expect most services to be started after mounting network filesystems, 
since pre-systemd Linux releases tended to do that. But it's too late to 
change the way default dependencies work now.


More information about the systemd-devel mailing list