A System Engineers outlook on the world

OSX Automounting NFS Shares

OS X has the wonderful Automounter service that will manage, well, automounting network disks for you. Edit the /etc/auto_master file and add in a line at the end that will reference your custom configuration file in the /etc/ folder:

1 #
2 # Automounter master map
3 #
4 +auto_master            # Use directory service
5 /net                    -hosts          -nobrowse,nosuid
6 /home                   auto_home       -nobrowse
7 /Network/Servers        -fstab
8 /-                      -static
9 /mnt/media              media_automount

Line 9 above will tell the autmounter service to manage mount points in the /mnt/media folder based on the contents of the /etc/media_autmount file. Create the /mnt folder:

sudo mkdir /mnt

You can test the security of the NFS server and list the available mounts by running showmount -e

[ 2:15]:user@Server:/Users/user$ showmount -e
Exports list on

In this example, the /volume/video folder has two subfolders, movies and TV Shows. Create the /etc/media_automount file and add in the folders you want the automounter service to manage:

movies      -fstype=nfs
tv_shows    -fstype=nfs"/shared/video/TV Shows"
music       -fstype=nfs

In this case, we are managing 3 NFS folders off the server with path /shared/video and /shared/music

After restarting the automounter service with a automount -vc as root, your /mnt/media folder should look like:

[19:47]:user@Server:/Users/user# ll /mnt/media/
total 8
dr-xr-xr-x  2 root  wheel    1 Jul 22 18:43 .
drwxr-xr-x  3 root  admin  102 Jul 12 18:38 ..
dr-xr-xr-x  2 root  wheel    1 Jul 23 14:47 movies
dr-xr-xr-x  2 root  wheel    1 Jul 23 14:47 music
dr-xr-xr-x  2 root  wheel    1 Jul 23 14:47 tvshows

Enjoy your centralized repo for media files. I use an old PowerPC Mac Mini as an iTunes server to stream media to the assorted iPads and an AppleTV in the livingroom. I also have a RaspberryPi running Kodi pulling media from the same NFS server in the basement family room.