[systemd-devel] automount nested nfs share

Lennart Poettering lennart at poettering.net
Wed May 4 09:41:18 UTC 2016


On Wed, 04.05.16 10:40, Marco Giunta (giunta at sissa.it) wrote:

> Hi at all,
> I've a problem with automount features of systemd. I need to mount two nfs
> share in this way:
> 
> 
> /srv/nfs		nfs-server.example.com:/share1
> /srv/nfs/nested		nfs-server.example.com:/share2
> 
> 
> On my old RHEL6 workstation, I used autofs, but now, with a RHEL7
> workstation, I'd like to use systemd.
> 
> I've configure two mount units, and they work like a charm: the nfs export
> are mounted like I guess. Then, I've configured an automount unit for
> '/srv/nfs', and it works, BUT when I 've created an unit to automount
> '/srv/nfs/nested', and started it, immediately '/srv/nfs' has been mounted,
> and I cannot unmount it (device is busy).
> 
> If I stop '/srv/nfs/nested' automount service, I can unmount '/srv/nfs'. I'm
> trying to figure out the problem, and I think the reason is 'automatic
> dependencies':
> 
> """
> If an automount unit is beneath another mount unit in the file system
> hierarchy, both a requirement and an ordering dependency between both units
> are created automatically.
> """
> 
> in fact:
> 
> # systemctl list-dependencies srv-nfs-nested.automount
> srv-nfs-nested.automount
>   -.mount
>   srv-nfs.mount
> 
> 
> 'srv-nfs-nested.automount' depends on 'srv-nfs.mount'. I don't want this, I
> want the 'srv-nfs-nested.automount' depends on 'srv-nfs.automount', because
> I don't want to have '/srv/nfs' always mounted, I need to mount it on
> request, I have more then 300 workstations to configure.
> 
> I've tried to change these settings:
> 
> DefaultDependencies = false
> Requires=srv-nfs.automount -.mount
> 
> but it doesn't works, because 'DefaultDependencies' doesn't disable all
> dependencies:
> 
> '''
> If set to false, this option does not disable all implicit dependencies,
> just non-essential ones.
> '''
> 
> So, my question is: is there a way to disable implicit dependencies ?? Or is
> there another way to automount nested nfs share with systemd ??

Well, we don't cover this without races right now, and I am not sure
we ever will. But you can make something like this work, that will be
racy, however, by marking your inner mount in fstab as "noauto". Then, pull in
the inner automount from the outer mount unit, via
Wants=. Specifically, add a drop-in
/etc/systemd/system/srv-nfs.mount.d/50-foobar.conf that contains this:

  [Unit]
  Wants=srv-nfs-nested.automount

This will make sure that the inner automount unit is only established
when the outer mount is actually delivered.

This will be racy however, as systemd will report back to the client
that the outer mount is established as soon as it activated the outer
mount, and won't wait for the establishing of the inner automount, so
that there's a short time-window were clients could access the inner
mount point without the automount being in place already.

So yeah, systemd doesn't cover this fully currently, and I am not sure
it really should in this case. Sorry!

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list