I have spent quite a bit of time figuring out automounts of NFS shares in OS X...
Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:
/etc/auto_master (see last line):
#
# Automounter master map
#
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
/- auto_nfs -nobrowse,nosuid
/etc/auto_nfs (this is all one line):
/Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
Make sure you:
sudo chmod 644 /etc/auto_nfs
Otherwise the automounter will not be able to read the config and fail with a ... parse_entry: getmapent for map failed...
error in /var/log/messages
This will not work (anymore!) though it "should".
$ sudo automount -cv
...
automount: /Volumes/my_mount: mountpoint unavailable
Note that, if you manually create the mount point using mkdir
, it will mount.
But, upon restart, OS X removes the mount point, and automounting will fail.
It's so easy my jaw dropped when I figured it out. Basically, we trick OS X into thinking we're mounting somewhere else.
When you're talking about paths in just about any environment, the root folder is the highest path you can reach, whether it's C:\
(windows) or /
(*nix)
When you're at this path, attempting to reach the parent path, via ..
will keep you at the root path.
For example: /../../../../
is still just /
By now, a few of you have already figured it out.
Change your /etc/auto_nfs
config from (this is all one line):
/Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
For pre-Catalina: To (this is all one line)
/../Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
For Catalina and up: To (this is all one line)
/System/Volumes/Data/../Data/Volumes/my_mount -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.1.1:/exports/my_share
And re-run the automounter:
$ sudo automount -cv
...
automount: /Volumes/my_mount: mounted
..... there you go! Technically /../Volumes
is still /Volumes
, but the automounter does not see things that way ;)
This configuration persists the mount across restarts, and creates the mountpoint automatically.
Feel free to send me large checks and/or high five the screen. [email protected]
There are a couple issues with your scenario. The first is that you will need to make sure the mount is a soft mount, or else you risk the filesystem locking up from what I have experienced. When you leave home, and the suddenly disappears, the NFS automounter will go out to lunch waiting for the NAS to come back online. The second issue is that of the drive icon. You could certainly create an automatic script that monitors the folder for change, and when detected, runs to create or delete the symbolic link on the desktop. This can be difficult to code, but once you get it right, it should work.
The easy solution for your issue is to use a utility to handle the mounts for you. I have used Expandrive for this. Since this is not a multi-user situation, you don’t need NFS, so I would use an AFP share or an SMBv3 share (as these are the fastest) but they are limited to single user access to the mount, unless you make them accessible by the guest/ anonymous user account (not recommended). Expandrive can mount all your NAS drive resources on demand, as well as many cloud drive services, and even SFTP/SSH paths as mountable resources. There are other mounting utilities as well, and you can surely do this with Automator scripts. But this autofs solution probably isn’t the right tool for this. At least, I would not use it for your situation. This is exactly what I use Expandrive for on my MacBook. Expandrive is not free, and they make you pay for every major version upgrade.