Nfs – using chained automount to mount home directory

autofsautomountmountnfs

I have set up two directories mounted with automount (via LDAP):

in the /home directory automount is configured to mount

*   -fstype=bind :/network/srv/home/&

in the /network directory one entry

srv    -fstype=nfs4,rw,sec=sys,noatime,hard,intr,proto=tcp,timeo=100,port=2049 myserver:/

when i try to access the home directory of a user (e.g. ls /home/myuser), automount fails with the error message:

>> mount: special device /network/srv/home/myuser does not exist
failed to mount /home/myuser

when i do the 'bind mount' manually using

mount -o bind /network/srv/home/myuser /home/myuser

automount for /network/srv is triggered and the myuser home directory is successfully mounted to /home/myuser.

Any ideas how to tell automount to load the /network/srv before trying to mount /network/srv/home/myuser???

Best Answer

I've encountered the same problem on Ubuntu 16.04 (autofs 5.1.1), but this doesn't happen on CentOS 7 (autofs 5.0.7, but with many patches). I worked around this by mounting directly rather than bind-mounting, with entries of this form in /etc/auto.home:

* -fstype=nfs4,rw,sec=sys,noatime,hard,intr,proto=tcp,timeo=100,port=2049 myserver:/home/&

I'd also much rather use a bind mount into a /net directory on both Ubuntu and CentOS, but this workaround works OK on both.

(I've not yet run through the large number of patches to see if there is something which was added to the CentOS version to fix the bind mounting, or if it's something which broke in a version of autofs after 5.0.7)