Automounting NFS Share – Fixing err=2, RPC: Timed Out

automountmacosnfs

I want to automount a nfs share whenever a user logs in to our Mac Minis. My original idea was to use the remote share as the place for the user's home directories, but due to being not able to mount the share, I'm just trying to get it mounted to an unrelated directory via autofs first.

My /etc/auto_master looks like this:

+auto_master
/net              -hosts -nobrowse,hidefromfinder,nosuid
/home             auto_home -nobrowse,hidefromfinder
/Network/Servers  -fstab
/-                -static
/-                auto_nfs -nobrowse,nosuid

My /etc/auto_nfs:

/home_tmp -fstype=nfs,vers=3,rw,resvport,tcp,soft,intr,rsize=8192,wsize=8192,noatime,timeo=900,retrans=3 192.168.0.2:/home_tmp 

The remote machine is running 4.9.11-1-ARCH x86_64 GNU/Linux and it's /etc/exports looks like

/home_tmp -nohide,sync,rw 192.168.0.0/26

and the share is also visible from the client:

$ showmount -e 192.168.0.2
Exports list on 192.168.0.2:
/home_tmp                           192.168.0.0/26

The machine trying to mount the nfs share is within the 192.168.0.0/26 subnet.

When I do a sudo mount -t nfs -o resvport,rw 192.168.0.2:/home_tmp /home_tmp, I can change into /home_tmp and see it's content. But when I try to change into this directory with automount, I get:

$ cd /home_tmp
-bash: cd: /home_tmp: No such file or directory

The system log shows:

automountd: MOUNT  REQUEST: name=/home_tmp [] map=auto_nfs opts=nobrowse,nosuid path=/home_tmp direct=1
automountd:   PUSH /etc/auto_nfs
automountd:   POP /etc/auto_nfs
automountd:   mapline:  -fstype=nfs,vers=3,rw,resvport,tcp,soft,intr,rsize=8192,wsize=8192,noatime,timeo=900,retrans=3 192.168.0.2:/home_tmp
automountd:   do_mount1:
automountd:   (nfs,nfs)   /home_tmp -vers=3,rw,resvport,tcp,soft,intr,rsize=8192,wsize=8192,noatime,timeo=900,retrans=3
automountd:               192.168.0.2:/home_tmp      penalty=0
automountd:   nfsmount: input:
automountd:       192.168.0.2[other]
automountd:       nfsmount: mount on /home_tmp vers=3,rw,resvport,tcp,soft,intr,rsize=8192,wsize=8192,noatime,timeo=900,retrans=3:
automountd:         192.168.0.2:/home_tmp
automountd:       ping: 192.168.0.2 request vers=3 min=3
automountd: pingnfs: 192.168.0.2: RPC: Timed out
automountd:       pingnfs FAIL: can't get nfs version
automountd: NFS server 192.168.0.2 not responding
automountd:       Couldn't mount 192.168.0.2:/home_tmp, err=2
automountd: MOUNT  REPLY  : status=2, AUTOFS_DONE
automountd: mount of /home_tmp failed: No such file or directory
automountd: MOUNT  REQUEST: name=/home_tmp [] map=auto_nfs opts=nobrowse,nosuid path=/home_tmp direct=1
automountd:   PUSH /etc/auto_nfs
automountd:   POP /etc/auto_nfs
automountd:   mapline:  -fstype=nfs,vers=3,rw,resvport,tcp,soft,intr,rsize=8192,wsize=8192,noatime,timeo=900,retrans=3 192.168.0.2:/home_tmp
automountd:   do_mount1:
automountd:   (nfs,nfs)   /home_tmp -vers=3,rw,resvport,tcp,soft,intr,rsize=8192,wsize=8192,noatime,timeo=900,retrans=3
automountd:               192.168.0.2:/home_tmp      penalty=0
automountd:   nfsmount: input:
automountd:       192.168.0.2[other]
automountd:       nfsmount: mount on /home_tmp vers=3,rw,resvport,tcp,soft,intr,rsize=8192,wsize=8192,noatime,timeo=900,retrans=3:
automountd:         192.168.0.2:/home_tmp
automountd:       Couldn't mount 192.168.0.2:/home_tmp, err=2
automountd: MOUNT  REPLY  : status=2, AUTOFS_DONE
automountd: automountd exited

I read somewhere that this RPC: Timed out error can be caused by the nfs-server being started before some other service, so I restarted the nfs-server, but without effect. Any advice welcome to solve this…

Best Answer

Your Arch Linux distribution probably contains an NFSv4 server. The NFSv4 server requires a base directory (e.g. /srv/nfs4).

Any additional share has to be a subdirectory (e.g. /srv/nfs4/home_tmp). So move the server-side /home_tmp to the base directory.

The file /etc/exports looks like this then:

/srv/nfsv4 192.168.0.0/26(rw,fsid=0,insecure,no_subtree_check,async)
/srv/nfsv4/home_tmp 192.168.0.0/26(rw,nohide,insecure,no_subtree_check,async)

(only tested with async but should also work with sync)

Reload the file with exportfs -arv on the server.

Your client-side file /etc/auto_nfs has to be changed also:

/home_tmp -fstype=nfs,vers=3,rw,resvport,tcp,soft,intr,rsize=8192,wsize=8192,noatime,timeo=900,retrans=3 192.168.0.2:/srv/nfsv4/home_tmp

Finally enter sudo automount -vc in the client's shell to "refresh" the mounted share.


To set up networked home directories for OS X users some directory integration is required or at least recommended (e.g. LDAP or AD). For Linux servers I've found a pretty old how-to: Automount OS X Home Directories Using OpenLDAP and Linux. I don't know if the approach still works well with newer macOS versions. An updated how-to would require a new question here or at Server Fault.