MacOS AutofS – How to Mount AFP Share Using Autofs

afpautofsautomountmacosmount

Current system, OSX 10.9.5

I've followed the instructions in this MacWorld hint and by reading the Apple doc for Autofs and several other places but I can't get autofs to automagically mount a remote AFP share on my NAS box:

$ sudo ls -l /private/etc | grep auto
-rw-r--r--   1 root   wheel     149 28 Jun 09:35 auto_home
-rw-r--r--   1 root   wheel     256 24 Oct 13:39 auto_master
-rw-r--r--@  1 root   wheel      97 24 Oct 13:39 auto_nas
-rw-r--r--   1 root   wheel    1935 28 Jun 09:35 autofs.conf

/etc/auto_master

#
# Automounter master map
#
/-                                  auto_nas    -nosuid  # this one is mine
+auto_master                        # Use directory service
/net                                -hosts      -nobrowse,hidefromfinder,nosuid
/home                               auto_home   -nobrowse,hidefromfinder
/Network/Servers                    -fstab
/-                                  -static

/etc/auto_nas

/Users/USER/Shares/Public   -fstype=afp afp://USER:PASSWORD@nasbox.local/Public

The permissions on the Shares directory:

$ ls -al /Users/USER | grep Shares
drwxr-xr-x    3 USER  staff     102 24 Oct 13:31 Shares

I've put nasbox.local in /etc/hosts and can ping it fine. I update the automount (I've also rebooted, no dice).

$ sudo automount -vc
automount: /net updated
automount: /home updated
automount: no unmounts

and…

$ cd /Users/USER/Shares/Public
cd:cd:13: no such file or directory: /Users/USER/Shares/Public

but, if I use mount_afp it mounts the directory fine:

$ mkdir /Users/USER/Shares/Public
$ mount_afp afp://USER:PASSWORD@nasbox.local/Public /Users/USER/Shares/Public

$ ls -l /Users/USER/Shares/Public 
total 3718056
long list of file follows…

Would anyone know what part of the incantation I'm missing to get the magic to work? I've tried all the obvious stuff like making the Public directory prior to mount, and changing permissions to it and Shares, using direct maps, indirect maps, wildcards… I've still not got this to work :-/

Any help or insight will be much appreciated.

Best Answer

Please create a folder Share in the User folder and change your auto_master to

/etc/auto_master

#
# Automounter master map
#
+auto_master                        # Use directory service
/Users/User/Share           auto_nas
/net                                -hosts      -nobrowse,hidefromfinder,nosuid
/home                               auto_home   -nobrowse,hidefromfinder
/Network/Servers                    -fstab
/-                                  -static

and

/etc/auto_nas

Shared_Folder -fstype=afp afp://User:Password@ip/Shared_Folder

enter sudo automount -vc in Terminal with the output:

$ sudo automount -vc
automount: /Users/User/Share updated
automount: /net updated
automount: /home updated
automount: no unmounts

Please regard the additional output: automount: /Users/User/Share updated

Both files need a trailing empty line or it won't work and you'll get the following error:
automount[pid]: map /etc/auto_master: line too long (max 4095 chars) or automount[pid]: map /etc/auto_nas: line too long (max 4095 chars)

(all tested and verified with a 10.9.5 client and 10.7.5 server)