How to auto mount NFS shares on Mavericks?

I need to mount at boot time the equivalent of the line command :

sudo mount -o rw,bg,hard,resvport,intr,noac,nfc,tcp mymachine:/var/logs /Volumes/logs

…and I have no idea about how to do it on Mac (OS X 10.9 Mavericks)

bash-3.2$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS HD                      499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS HD2                     499.8 GB   disk1s2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *668.2 MB   disk2
   1:        Apple_partition_map                         30.7 KB    disk2s1
   2:                  Apple_HFS OSXDocsetCD             668.1 MB   disk2s2
/dev/disk3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *477.6 MB   disk3
   1:        Apple_partition_map                         30.7 KB    disk3s1
   2:                  Apple_HFS DevToolsDocsetCD        477.6 MB   disk3s2
/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     Apple_partition_scheme                        *596.2 MB   disk4
   1:        Apple_partition_map                         30.7 KB    disk4s1
   2:                  Apple_HFS iOSDocsetCD             596.1 MB   disk4s2

Solution 1:

Using autofs, as suggested by others is probably the way to go. Most of what follows works in El Capitan, which made auto mounting more difficult, but it should apply to Mavericks too. I do not have a Mavericks system to test.

In order to make this work edit /etc/auto_master and add the following line:

/- auto_nfs -nobrowse,nosuid

Then create a new file /etc/auto_nfs (with permissions 644) with the following content:

/../Volumes/logs -fstype=nfs,nrw,bg,hard,resvport,intr,noac,nfc,tcp mymachine:/var/logs

You have to add the /.. in front of the /Volumes, because Mac OS X (at least El Capitan will try to prevent you from mounting thing in /Volumes and /../Volumes is still /Volumes, it just tricks the filter. This might not be necessary for Mavericks)

Then start the auto mount daemon

sudo automount -cv

and you should see that the volume has been mounted (ls /Volumes/logs)