Automatically connecting to a network (NAS) drive on demand on a Mac

I’ve recently been re-working my home network and it currently looks something a little like this:-

My Home Network

All of my multimedia files are stored on the NAS (Network attached storage) server. The Plex server mounts a few shared folders to access the media and present it to the Plex clients (the laptops, web ui, tablets etc)

To save on energy the Plex media server is set to sleep at night and then wakes up in the morning. It’s currently running on an old Mac Mini I had lying around. Unfortunately what I found was, after it woke up, the previously mapped networks drives (which were connected on user login). Didn’t reconnect after the system woke. Therefore Plex couldn’t access the media.

To resolve this I decided to use the automount functionality which (I believe) is on most *nix based systems, of which Mac is one.

To achieve this, I performed the following steps.

In /etc/auto_master I added the following line (you’ll probably have to do this as sudo)


/media auto_media

I then created a file /etc/auto_media, which has something similar to the following

LOW_DEF_MOVIES -fstype=smbfs,soft ://<username>:<password>@<nas-server>/LOW_DEF_MOVIES
HIGH_DEF_MOVIES -fstype=smbfs,soft ://<username>:<password>@<nas-server>/HIGH_DEF_MOVIES

Replace , with the username and password required to access the files on your network share, in my case, it’s a Samba share. Also change to the IP or DNS name of your NAS server. The LOW_DEF_MOVIES in my case is the name of the shared folder on the NAS drive, you will have to replace it accordingly as well.

Once you have those files in place, type

sudo automount -vc

for the changes to take affect. You should now be able to “cd” into your Network drive.

cd /media/LOW_DEF_MOVIES

and see all your required content.

To make sure not everyone can see your username and password (my biggest gripe with this approach). You need to change your file permissions, so only the owner and see and execute the auto_media file. To do this, enter the following command

sudo chmod 0700 /etc/auto_media

I have given a use case for the scenario I have, but the concept holds true for any network share you may require that needs to be auto mounted on demand. It doesn’t have to be anything to do with a NAS/Plex setup. That was just my use case.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.