When faced with a new macOS installation, I need to set up NAS shares to be automatically mounted to avoid the annoyance of macOS unmounting them on sleep or some other undefined interval and then having to remount them.
This is one of those scenarios where Windows does a much better job. Windows happily remembers the network share, and if disconnected from it, will attempt to re-connect.
There are a couple of approaches people have used to achieve similar on macOS, I know of two:
Mounting it manually, then dragging the mounted share to the login items for a user. Not quite my idea of discoverable, and I couldn’t get this to work reliably. It would either not show up again, or beach ball the crap out of Finder.
Using automount to mount the folder on access. This has the disadvantage of not showing up as a volume in the Finder sidebar by default, but this is easily remedied by adding it to Favorites. This is my preferred solution, and I’ll describe it in detail.
Add an automounter mapping
/etc/auto_master, and add an entry for NAS mappings. I like to mount my various NAS shares under
Example entry in
Make sure the directory you specify already exists.
For more details on the syntax of this file, see the
auto_master man page.
Create the NAS mapping file
Create the file
/etc/auto_nas, and add an entry for each NAS share you want to mount.
Media -fstype=smbfs ://USER:PASS@SERVER/SHARE
I usually use an IP address for
SERVER, to avoid any problems with DNS.
You want to ensure the permissions of this file prevents any non-root user from seeing its contents, as you need the user credentials in there for the automounter.
Reload the automounter
$ sudo automount -vc
You should see output like:
automount: /net updated automount: /home updated automount: /Network/NAS updated automount: no unmounts
Check whether it worked by opening the base directory (
/Network/NAS in my example), in Finder.
If it did, you should see a volume icon representing the share (
Media in my example).
You can then drag this into your Favorites bar, and it will automatically mount whenever you try to access it, with no password prompt.