I'm currently running a setup at home, which involves having a Synology DiskStation in my home office, and streaming media to the rest of the appartment from there.

In our living room, I have a Mac Mini that have been using SMB/CIFS mounts to handle media mounts from the Synology for some time, but I've experienced some issues with playback, especially in regards to 1080P HD streams, so I decided to switch to NFS mounts instead, as the performance is supposedly better for continuous streaming.

Please note before you continue: Finder won't show these mounts by default, and so you'll have to access them through Command+G and typing the path. So, if you're using NFS for browsing through Finder, this may not be for you. This is meant for automating purposes, like getting Plex to stream from a remote NAS.

Why automounting?

There's a bunch of guides for simple mounting of NFS shares, and even an app called NFS Manager to make the process simpler.

However, as I don't want to manually mount the Synology shares everytime my Mac Mini is rebooted, or everytime my Synology has been shut down, automatically mounting the shares is a must.

Also, before Mountain Lion, Apple's own Disk Utility supported setting up NFS shares, but as that feature has been removed, another solution was required.

Creating a mount point

To get moving, we need a local mountpoint where the NFS shares will be mounted by Apple's own automount service. Apple usually mounts NFS under /Network, but I prefer having my shares accessible through /Volumes, as that's the location external drives are mounted as well. So, let's create a Shares folder in /Volumes, by firing up the Terminal and typing

mkdir /Volumes/Shares

Adding a master map

automount has it's own configuration, which determines the directories handled through automount. This is located in /etc/auto_master

Now, there's basically 2 ways to handle the configuration. Either do it inline in the /etc/auto_master file, or delegate it to a seperate configurationfile for a given directory.

This allows you to seperate different mounts from eachother, and makes the main auto_master file less crowded, so fire up /etc/auto_master and add the following line to it:

/Volumes/Shares      auto_shares

Now, your /etc/auto_master file should look like this:

# Automounter master map
/Volumes/Shares		auto_shares
+auto_master		# Use directory service
/net				-hosts          -nobrowse,hidefromfinder,nosuid
/home				auto_home       -nobrowse,hidefromfinder
/Network/Servers	-fstab
/-					-static

Mapping the new shares

So, now auto_master assumes /etc/auto_shares is available, and will look to that, to figure out what to do when you access a diretory within /Volumes/Shares. Now, I have an NFS share called video on my Synology, which I want to mount at /Volumes/Shares/video

So, create the /etc/auto_shares file, and add the following line:

video	-fstype=nfs,soft,intr,rsize=32768,wsize=32768,noatime,timeo=900,retrans=3,proto=tcp <hostname/ip of the NFS server>:/video

Now, there's a few things to this:

  • The line above assumes anonymous access is allowed on the share. If you have to use a password, the mount part of the line would look like this: username:password@<hostname/ip of the NFS server>/video
  • You'll notice that there's a lot of options in that line. I'm not going to go over all of them, but they are there for improving performance of the share. In the bottom of the post are a couple of resources on the details of improving NFS performance.

Activating the mounts

Whenever you change automount's configuration, you'll need to load them through the service:

sudo automount -vc

And that's basically it! Your Mac should now mount the volume when your scripts/Plex/etc. access the directory associated with it.

More resources on NFS tuning

Tune NFS Performance

Tuning NFS for better performance