AFP automatic mount on OSX

Hi everybody,
You can use fancy Apple scripts or payed applications to do the work but still experience issues when the NAS reboots or the network drops. I think the Mac is widely underestimated here because he can do so much more and there is a very elegant solution available since 10.5 for that, called autofs.

True to the point people have been writing about this feature already on this forum you can find a nice post by puithove here. And there are of course a handful of guides on the net as well. In case you want to know all the details have a look at this nice guide by Rajeev (Part1 and Part2) or have a look at the official white paper by Apple here.
This looks all quite difficult and scary but just getting AFP/SMB shares to mount automatically upon access you just need to add one line to your /etc/fstab file. So I thought it might be about time to write a short in a nutshell howto to get more people to use this feature.
In principal this is a four step procedure so here we go:

So first of all we need to create mount points, i.e. the point in your file system you want to attach your shares to. For that I created a folder called ‚Shares‘ in my home directory and added a subfolder ‚Movies‘ to which I want to attach my Movies share from my NAS. I will use this as an example here but you can put those folders anywhere you like. The real power already becomes apparent here. This is not a share you automatically mount to your desktop. This is just a folder on your file system. Whenever you access that folder your Mac will access the share in the background. So the integration is seamless and no one working on the system or no program can tell the difference from a normal folder.
The next step requires editing the fstab config file situated in /etc/fstab. Fire up the Terminal and type

sudo nano /etc/fstab

if you don’t like nano you can use any other text editor but then you are on your own. You will be prompted for your password and then nano opens the file. This file should be empty. Enter the following lines into the file. You need to replace YOUR_NAS, YOUR_SHARE, YOUR_LOGON, YOUR_PASS and /Users/simon/Shares/Movies with the name of your NAS, the name of your share on the NAS, your logon, your password and the path to your mount point (see step 1) respectively.

  • Mount AFP shares from YOUR_NAS
YOUR_NAS:/YOUR_SHARE /Users/simon/Shares/Movies url automounted,url==afp://YOUR_LOGON:YOUR_PASS@YOUR_NAS/YOUR_SHARE 0 0
  • Mount SMB shares from YOUR_NAS
YOUR_NAS:/YOUR_SHARE /Users/simon/Shares/Movies url automounted,url==cifs://YOUR_LOGON:YOUR_PASS@YOUR_NAS/YOUR_SHARE 0 0

Type CTRL+O followed by RETURN to save the file and CTRL+X to exit nano.

Now you can reboot your Mac to make it active or even better you can just issue the command

sudo automount -vc

If everything was set up correctly you should get a reply similar to this:

automount: /net updated
automount: /home updated
automount: /Users/simon/Shares/Movies mounted
automount: no unmounts

Now you can try to open your mount point folder and you should see the contents of your share in there. Neat ain’t it 🙂

As the final step you can now add that folder as a source to Plex. Please don’t forget to disable your previous automount solution as in Leopard you did have problems accessing the mount point when the share was already mounted on the desktop. I just tested this in Snow Leopard and there the limitation doesn’t exist anymore. Then you are ready to go.
I have been using this set up for more then a year now and haven’t had a single outage no matter how I restart my NAS or my Mac etc. Also hibernation of my NAS is not an issue as autofs disconnects if the share is not used and then re-connects if you need it. So my NAS is not suffering from insomnia in any way.

Oroginal language: English

source -> https://forums.plex.tv/index.php/topic/14201-howto-automount-afpsmb-shares-using-autofs/