Autofs with remote and local home directories at same folder

autofshomemountnfs

I have a NFS server exporting home directories for remote users and the workstations have local and remote users. I want to configure autofs to mount a remote user home directory as a subdirectory of /home directory.

I configured the autofs to mount the nfs shares, however when a remote share was mount the local home directories gone away.

Is there a way of mounting only the directories that does not exists in the /home directory? Is there a way that is not configured by setting by hand all the local folders, automatically discovering each existent directory and skipping the mount of it?

Thanks

Best Answer

I just solved a similar issue. I wanted to mount a few users' /home/username directories from nfs, but have a couple others live on the local disk. Unfortunately, when trying to use the local disk directory, I was running into permissions errors.

After some research, I read man auto.master 5 a bit more carefully, and found this:

For direct maps the mount point is always specified as:
     /-
and the key used within the direct map is the full path to the 
mount point. The direct map may have multiple entries in the  master map.

So, in auto.master, you would have a line like:

/- auto.misc --timeout 60

In auto.misc:

/home/remoteuser <options> <nfsserver>:<path to home dir>

You can still have indirect mounts in the auto.misc file if you want. Just depends on how you want to organize your map files.

Note, this is on Ubuntu 16.04 and automount 5.1.1. I have not tested this on other OSes yet.

Related Question