Keep Network Drives Mounted on Mac OS X using Autofs

I have a Apple Mac Mini that I use as a HTPC using Plex. Connected to the Mac are two USB external drives, one called Media for movies, TV shows, etc… and the other one called PersonalMedia for photos and camcorder/home videos. I recently bought a Synology NAS, and copied the contents of the PersonalMedia into the Synology using RAID 1 redundancy (2x 2TB WD Red). With the NAS mounted using Finder and adding it to the “Login Item” for automatic mounting, I was all set, or so I thought…

The Synology NAS is set to spin down the disks after 20 minutes of inactivity and wake on LAN when requested (WOL), which is great as it’ll preserve the life of the disks and of course use less power consumption when not in use. The problem is that the Mac will only attempt to connect to the NAS on power up from cold start/restart or from sleep. So if I’m using the Mac, but not accessing the PersonalMedia share, then after 20 minutes the NAS will go to sleep and the network drive will disconnect, and the only way to reconnect is using the Finder option, Connect to Server [CMD+K] or performing a restart.

This is more of an issue with Plex, as the disconnected share is not accessible when you try to access the Plex library for that share, Plex returns an error – understandibly as the drive is no longer available.

autofs is a utility that will mount network volumes on your OS X system, just like you would do through the Finder. However, unlike drives mounted manually through the Finder, or even by a “Login Item” at login time, autofs mounted volumes will automatically connect and reconnect as needed whenever the network volumes are available, and quietly disconnect when they’re not. The same benefits apply to devices that may live permanently on your network, but regularly go to sleep and need to reliably re-mount volumes on wake.

Using autofs means that whilst my Mac is awake, it will continously attempt to mount the PersonalMedia share on the NAS – whether it’s being used or not – effectivily disabling the NAS’s ability to sleep. Then 20 minutes after the Mac has gone to sleep, so will the NAS (assuming no other resource is accessing the NAS) – Win Win!

Step 1 – Open the

Either start typing Terminal in the Spotlight search, or goto Applications > Utilities > Terminal.

Step 2 – Open auto_master

Open the auto_master file by typing the following in the Terminal window:

$ sudo nano /etc/auto_master

Type your user password when prompted.

Step 3 – Edit auto_master

This will bring up a text editor containing the auto_master file. Simply append your new mappings underneath the default ones.

# Automounter master map
+auto_master		# Use directory service
/net			-hosts		-nobrowse,hidefromfinder,nosuid
/home			auto_home	-nobrowse,hidefromfinder
/Network/Servers	-fstab
/-			-static
/mnt/NAS		auto_nas

The first column /mnt/NAS specifies where you would like your mounted volume to appear. You can replace this with a path of your choice.

On Mac OS X 10.9 and later, do not use /Volumes as your mount point since everything that’s not a physical volume (hard disk), including your mount point directory, will be removed whenever the machine is rebooted.

The second column is the name of a file that we will create in Step 5. It can also be named anything you want.

Step 4 – Save auto_master

When done, press Control+X to exit.

Press Y when prompted to save the changes

Press Enter to accept the suggested path

Step 5 – Create auto_nas

We need to create the file that autofs will refer to for details about your individual mounts. With the Terminal window still open, create the auto_nas file

$ sudo nano /etc/auto_nas

Type your user password when prompted.

Step 6 – Edit auto_nas

This will bring up a text editor containing the new empty auto_nas file.

Add a line in this file for each mount point

PersonalMedia -fstype=afp afp://username:password@


PersonalMedia -fstype=smbfs ://username:password@nas/PersonalMedia

In this example, PersonalMedia is the name of the directory that will appear under your mount point specified in Step 3. -fstype=afp tells autofs to use the AFP share protocol, similarly -fstype=smbfs tells autofs to use the SMB share protocol. Replace username:password values with your own. Finally, replace the IP address or hostname with that of your NAS, and the path with the name of your share.

The hostname of the remote device must be in the local /etc/hosts file or otherwise defined by DNS. On my local system I simply include it in the /etc/hosts file.

Step 7 – Save auto_nas

When done, press Control+X to exit.

Press Y when prompted to save the changes

Press Enter to accept the suggested path

Step 8 – [OPTIONAL] Security

Since the auto_nas file potentially contains password information, you may want to make sure only the root user can read it. Enter the following command in the Terminal window

$ sudo chmod 600 /etc/auto_nas

Step 9 – Create mount directory

If the directory you specified in Step 3. (auto_master) above doesn’t exist for your mount to appear, you’ll need to create one, either using Finder or Terminal. In my case I needed to create the directory structure /mnt/NAS.

Step 10 – Execute autofs to mount the shares

With the Terminal window still open, enter the following command to mount the new shares

$ sudo automount -vc

You should see some output similar to this

automount: /net updated
automount: /home updated
automount: /mnt/NAS mounted
automount: no unmounts

From now on, everything will be automatic. Your shares will automatically be mounted and they will stay connected as long as they’re available on the network.

Step 11 – Finish

Make sure the new directory exists and you can navigate to it and see its contents, either through Finder or Terminal

$ cd /mnt/NAS/PersonalMedia
$ ls


  1. I’m looking into buying a Synology NAS (1515+ or 1818+ probably).

    Why go through the exercise with `autofs` when you can just disable “HDD Hibernation” on the NAS? (In DSM 5.2 it’s even in Control Panel » Hardware & Power » HDD Hibernation).

    Do you use Finder and have a problem with folders one the NAS displaying very slowly?

    1. John, as mentioned earlier in the post, it’s better to let the NAS goto sleep when you’re not needing to access it. Helps preserve the life of the disks, and reduces power consumption.

  2. Thanks for this article as it was quite helpful for me in setting up my nas and mac.

    A couple suggested edits:
    Step 5: the file should be auto_afp not auto-afp in the highlighted text in the description.
    Step 8: the file should be auto_afp not auto_smb in the command

  3. Thank you for your useful and helpful article. I shared it on Plex forums as this was something many people try to do to mount network volumes to their Mac mini servers.

    Just one question, have you had issues in how long it takes for your computer to show the contents of the shares?

    1. Hi Michael, I haven’t noticed any issues, to be honest. As Plex Server is running on the Mac Mini, the library is already up and running so there so by the time I start Plex HT and navigate to the media I want to watch, and then click to play, the drive is already mounted and ready to go.

  4. Hi Rajesh,

    Thanks for this detailed overview, I’m having this exact problem since a recent upgrade (either to El Capitan or DSM 5.2) and it’s driving me crazy !

    I’m following all the steps and i get a mounted share appear in the location i asked… but the file size is zero and the contents of the NAS aren’t visable.

    The frustrating thing is I’ve had it working once, but then stupidly tried to change the location of where i wanted the mounted drive to appear, it broke again. Now no matter what I try i just can’t get it to mount and show me the files.. Help !

    (I can acces my NAS so I know its on the network, i just want it to stay there :-)

    1. Hi John, Which protocol are you using for the autofs? I was initially using the AFP protocol, which worked fine, but recently when I tried Plex, it kept failing saying media not available. I checked all settings and ran the automount cmd several times, which never generated an error, but still couldn’t navigate to the location – similar to yourself I guess. I ended up removing the AFP protocol and used SMB instead, exactly the same steps, process, and names, but different protocol. When I then ran automount everything seemed to work fine, and has been running since (+4 weeks).

      1. Hi Rajesh,

        Thanks for the reply, I did initially try AFP so I will give SMB a try.

        One other question about putting the hostname in, do i put the Synology IP and the Synology server name there?

        1. Hi John, either the Synology IP address or its Server name. For example my Server name is called NAS and its IP address is If using the Server name just make sure that your Mac can resolve to the Synology, if not you’ll need to add an entry to your hosts file. Easiest way to do this is open up Terminal and enter Ping <server-name>, if you get a response all good, else add it to the hosts file.

  5. Thanks Rajesh,

    Great article and exactly my issue with my Plex server running on a 95% stationary MacBook, but my NAS (afp) is actually an external USB Lacie drive connected to an Apple Time Capsule but the sleep behaviour is the same and there are not even any settings on the TC to change this. I can’t get this to work though and I feel it may be related to my share using the Time Capsule device password to authenticate, I can’t seem to pass this on as just :@ without doesn’t work. I can’t change it back to user level authentication as I can’t see any files wont he drive after I do.

    Any ideas? Thanks!

      1. Small update, I managed to get around the password issue, I use user accounts on the Time Capsule now and log in with the Admin account and device password so I can see all files. I also managed to mount the drive correctly via Terminal:

        mount_afp ‘afp://admin:devicepassword@AirPort Time Capsule._afpovertcp._tcp.local/LaCie’ /mnt/NAS

        But the issue is that automount won’t work.
        auto_master line:
        /mnt/NAS -auto_afp

        auto_afp content:
        Lacie -fstype=afp ‘afp://admin:devicepassword@AirPort Time Capsule._afpovertcp._tcp.local/LaCie’

        I get the following auto mount output:
        automount: /net updated
        automount: /home updated
        automount: /mnt/NAS updated
        automount: no unmounts

        But I can’t cd into the ‘Lacie’ share and the /mnt/NAS folder changes it’s icon to a network share but is otherwise empty. Any idea?

        1. Try removing the entry from auto_masters, then run the automount cmd, reboot the system and try and add the entry back in. If that doesn’t work, try creating a new file, e.g. auto_lacie and create the necessary entry points to see if that works, finally if all fails, and if viable, try using the smbfs protocol.

  6. Thank very much for your help in this, but I’m still struggling with mounting my file.
    I want to have my file (video) mounted on my desktop (for easy of transferring films).
    I tried to follow your instructions, but at the end,it seems to fail. Please can you help.
    I’ve included some pics that may explain where I’m going wrong.
    # Automounter master map
    +auto_master # Use directory service
    /net -hosts -nobrowse,hidefromfinder,nosuid
    /home auto_home -nobrowse,hidefromfinder
    /Network/Servers -fstab
    /- -static
    /mnt/Desktop auto_video
    Draft Will Nikita King.doc
    Draft Will Steven King.doc
    Incompatible Software
    Retrieved Contents

    by the way, many thanks for trying to help people like me.

  7. I can’t past the first step, I tried to call the Auto_master file but keep getting error that command is not found… I’m a newbie to this mac stuff.
    So you meant to tell me.. that ancient, old fashioned Windoze mount drive or share is waaayy superior to anything in Mac OS X? That’s utterly amazing, to have to jump through these hoops to mount a share? It’s the only thing stopping me from using a mac mini as Plex server (what I bought it for – but what a waste).
    Windows sucks in many departments, but its a whole lot better with managing networking it seems.
    I’m a little stuck now, my Win 7 VM is too slow for Plex, and NAS’s are just too expensive and even slower for Plex… so I guess a dedicated Windows box for Plex server is the next best thing…grudgingly but hey Cupertino can’t seem to get networking basics right.

  8. Hey all. This all sounds great. However, I am new to all this and I do not write code. I just bought a QNAP TS-251 and successfully transferred all my media but I am having the issue you reference above. I am fearful that if I attempt this recommended step I may screw something up. So, can you provide exact, step by step directions? In step 4 or 5 you reference not naming it “volume/” so I am not clear on what that means exactly and if there is a step there that is inferred that I do not know. Thanks for any help!!

  9. I don’t know whether this is a 10.11 thing but I’m finding that after following these instructions for my Sinology NAS it doesn’t initially mount until I try and access the folder, is that correct? In Finder it appears as a regular folder until I click on it, at which point it “wakes up” and turns into a network share.

    So this made it useless, for example, for Acronis True Image backup because when this software loaded it just said “Destination not available”.

    I thought from the description above that it is meant to setup the mount fully right away?

  10. Is there a way to get these mount points to show on the desktop like a normal connected share, or should I just sym link to the folders in the /mnt/NAS directory?


    1. I found that the most convenient thing was to symlink the NAS mount point to the desktop. So, from Terminal, and using Rajesh’s original example:

      ln -s /mnt/NAS /Users//Desktop/NAS

      That way you have a Desktop ‘folder’ with all your mount points.


  11. I think there is something going on with 10.11 that breaks the procedure for mounting AFP shares into user directories. I am trying to mount afp://user:pass@myserver.local/Music to /Users/me/Test

    auto_master has the line:
    /- auto_afp -nosuid

    auto_afp has the line:
    /Users/me/Test -fstype=afp afp://serveuser:servepass@server.local/Music

    The server mounts beautifully, but clicking on the server icon in /Users/me gives the error “The folder “Test” can’t be opened because you don’t have permission to see its contents.”

    After working the problem through, I see that this is a permissions problem. The mount point has the owner and group and permissions:
    drwx——@ 1 root wheel 364 31 Dec 10:01 Test
    (Actually, it’s interesting — if I empty out my auto_afp file and reboot, this returns to a regular directory with owner/group/permissions drwx——+ 18 me staff 612 31 Dec 10:01 Test)

    So the problem here is that autofs is mounting the share with root privilege, and my user cannot actually use the share. From my reading on the web, this appears to be a relatively new problem — perhaps El Capitan related?

    For comparison, when I do the following (as a user, not as a system user or using ‘sudo’):
    Create a new folder from the finder at /Users/me called ‘Test3′
    then from the terminal enter:
    mount -o nosuid -t afp afp://serveuser:servepass@server.local/Music /Users/me/Test3

    then the server mounts beautifully (albeit with the finder name “Music”, which I would prefer to change), and has the following user/group/permissions:
    drwx——@ 1 me staff 364 31 Dec 10:21 Test3
    and I am able to see and manipulate the contents.

    So in summary, the problem is: How can I get autofs to mount a network AFP share and map it into a user directory so that the user can access it and manipulate its contents? Historically, I think this is exactly how autofs is supposed to work, but it seems that the ownership of the mapped folder by ‘root wheel’ prevents it now from being of any real use.

    One more matter, while I’m at it: I have fallen back to the simple goal outlined above, but my longer-term goal is to map an external music folder to EACH user. auto_afp should look like this:

    /Users/me/Test -fstype=afp afp://serveuser:servepass@server.local/Music
    /Users/her/Test -fstype=afp afp://serveuser:servepass@server.local/Music
    /Users/him/Test -fstype=afp afp://serveuser:servepass@server.local/Music

    I know that I can make this mount in each users’ login items, but that’s not actually good enough to achieve my long-term needs. Long term, I need this folder mounted at boot by autofs to make it available for cloud backup.

    I would really appreciate any help or insight you can offer! Thanks for reading.

    1. Hi Mark.
      Try using indirect automout map instead of direct (See AutoFS whitepaper). I got this hint from Apple via bugtracker. Config should look like this:

      auto_master has the line:
      /Users/me/mount auto_afp -nosuid

      auto_afp has the line:
      Test -fstype=afp afp://serveuser:servepass@server.local/Music

      1. Using an indirect map doesn’t help either. This functionality seems to be fundamentally broken in OSX going back to at least Yosemite… I’ve dug through 3 years worth of posts of people having this same issue and as far as I can tell, there’s simply no way to share a mount point across users… what an huge, infuriating, unbelievable fail.

        Thanks apple!

        1. Ben, I have done what you have done, with the same result. I just want to confirm that there seems to be no solution to this. Sad.

          1. Have you reported this to Apple? I’m seeing this with BOTH SMB and AFP. I’ve also tried to do this with root mount points and have similar failures.

          2. One option is to enable root, and logon as root. Once you do that it all starts working. Crap option, I know, but my use case is a media server on an isolated network. Only option until I can see until apple gets it head out of its arse.

  12. Hello Rajesh Patel,

    after a long time I found your solution for my NAS … everything works like a charm … But now I realised that something is not working as it could … Do you have any solution for the following:

    autofs only works like a charm on machines that are always connected to a network because of the delay issue if for example you leave your home network and restart your MacBook …

    Let’s say you take your MacBook to a friend and a new network (not known) and try to open/save files from the Finder … you will get stuck into a big delay and not responding applications and the MacBook keeps trying to mount the NAS drives continuously …

    Is it possible to avoid this ? Any help or feedback would be great !

    Best wishes,

  13. Nice!
    Is there ANY way to have this feature check if i am in my local network or on a remote network (like “if ‘localNAS-IP’ not reachable THEN auto-mnt ‘’) so I can have the same mount, no matter where i am (as long as i am online, of course)

    That feature i miss in every mount tool (like expandrive, autoMount, Mountdrive, etc)…

    Thank You


  14. Hi,

    Thanks for taking the time to write this post.

    I have a Plex server on a Mac mini and the drive disconnecting drives me nuts. I have it set to connect when the Mac mini boots up but if the NAS reboots or gets unplugged from the network if never remounts unless I remote desktop to it and do it manually. Pain! So I really want to get this working.

    I am struggling to understand the first part where I edit the auto master. With the file path. I literally just want it to mount one particular share on the NAS and I want it to appear as mounted in the Finder sidebar as well as appear on the Desktop like it usually would. Can you tell me what path I would use for that.

    Thanks in advance.


  15. Every step of this worked fine, until I rebooted the system.All I get is a black screen with the cursor. I then use target disk mode to edit the auto_master file and then its all fine again.

    Is it because I go to a login page and it is trying to connect before I have logged in and that I am part of a domain?

  16. Hi Rajesh,
    Will this work for an external hard drive attached to an Airport Extreme Base Station? I am looking for a solution which will allow the network drive to automatically mount and eject from my Macbook Pro as I come and go from my home. Thanks, great info!

  17. Hello…
    I have tried, it work! GREAT JOB!
    i tried with local network (afp/smb) it working fine. But when i try to connect with far connection (mount SMB via VPN in other side latency 300-400ms) it can’t get any information.

    Do you have any idea ?

    Thank you in advice!
    Nick :)

  18. Awesome article, thanks for posting. I pretty much have the same setup, just moved my Plex from my MBP to a dedicated Mac Mini on 10.11 and switch my growing media library from a USB drive to a Synology 1515+ .. accessing the media away from home was an issue with the files not being available.

    Thanks mate :-)

    Sydney, Australia

  19. Hi Rajesh,

    Awesome article and it works perfectly.
    I have two questions.
    1. I have Plex on a Mac Mini and my movies on a Synology NAS. What is the best protocol for connecting those, AFP of SMB and why?
    2. Can you setup automount to only work on a specified network? I would like my MacBook to connect to the drives when I am at home but don’t want any issues on other networks.

    Regards, Patrick

  20. Hello,

    Thank you for the post, it looks like this will be the solution for me !
    BUT I can’t get it to work ?
    I’ve tried AFP and SMB variants, it creates the mnt/NAS/PersonalMedia dir but no drives are visible ?

    Could you help me try to find what I do wrong ?

    thank you


  21. I’m having a big time issue. I am using an Airport Time Capsule and it simply won’t mount. In Finder Connect to Server, I can go to cifs://username:password@cbtc/Data/iTunes (iTunes Library in that folder) and it will pull it up right away. So I do all that in the auto_nas file, and I run automount -vc but it simply shows it as blank. What am I doing wrong?

  22. Thank you this was massively helpful. I was having a very similar problem with a Drobo 5n. It kept in mounting and having to manually reconnect to watch stuff on Plex was driving me insane. This solved the problem. Thank again.

  23. Can you explain how we create this directory?
    “If the directory you specified in Step 3. (auto_master) above doesn’t exist for your mount to appear, you’ll need to create one, either using Finder or Terminal. In my case I needed to create the directory structure /mnt/NAS.”

    1. From the terminal, that would be:
      sudo mkdir -p /mnt/NAS

      That’s a “make directory” command, with the -p flag so that in case the parent directory /mnt doesn’t already exist, that one will be created too, before the attempt to create /mnt/NAS.

  24. Hi Rajesh! That article has a great value! Thank a lot for that and the perfect documentation. I had similar troubles to mount my NAS connected with at my Especially when running backup scripts by jenkins to save documents. My script for mounting the network drive does not work properly at all. Additionally I do not find out how to define another mount point instead of the given by device:

    on mountFB()
    set the_server to “smb://″
    tell application “Finder”
    mount volume the_server
    end tell
    end try
    end mountFB

    1. I haven’t tried it yet, but perhaps sshfs might do the trick for you if it’s an option to open ssh on your firewall. In this setup you don’t necessarily need VPN. I might try it myself when I find the time to do it.

  25. You’ve got a typo in the samba step
    PersonalMedia -fstype=smbfs ://username:password@nas/PersonalMedia
    It’s missing the smb in the scheme

  26. Thanks Rajesh. Nice write up!
    I’m in same situation, except I’m using an unRAID server for my media NAS.
    Just thought I’d point out you still have one small typo: In step 6 you’ve missed the ‘smb’ before the ‘:’
    ie. It should read: smb://username:password@nas/PersonalMedia
    Although obvious to IT people, this may trip-up some of your visitors setting up smb automount’s.

    1. Hi Rajesh,
      You can ignore my comment above regarding the ‘smb:’ protocol prefix, as it indeed isn’t required. Mind you, I’ve still included the full smb:// protocol prefixed link, just to be explicit.
      I am however having the same issue which others have also noted elsewhere. This is with automount’d shares occasionally becoming inaccessible, due to their ownership being taken over by root with exclusive access. This appears to require a ‘sudo umount’ of the share, to allow the current user to regain ownership, and access to the mounted share. Unfortunately, I haven’t found a “nice” solution to this as yet.

  27. This has worked perfectly for me for sometime now. But I recently upgraded to Sierra and now my mounts randomly unmount and will not remount until I reboot. Is anyone else experiencing this problem? Does anyone have a solution?

    1. Hi Derek. What you describe sounds like the same problem I described above (my Nov 14 reply). In my case the mounted shares (which you cannot see / access) had been taken over exclusively by root. eg. if you open terminal and do a ‘sudo ls -all’ over your mount folder (eg. /mnt/NAS in Rajesh’s example), you’d see the missing shares still mounted, but now owned by root with exclusive rights (ie. 700). In my case you could avoid a full reboot by sudo unmount of the affected share (ie. ‘sudo umount /mnt/NAS/SharedFolderName’). In my case this then allowed the current user to immediately re-take ownership (until it randomly happened again to this, or another share mount). But I haven’t found a ‘nice’ solution to this yet. Let me know if you are seeing identical issue & if you find the solution. Cheers.

      1. Great article and it’s working well for me. I’m also having some shares drop randomly from finder. They appear to still be there when listing folder contents in terminal and the sudo umount solution works to bring them back.
        It would be great if we could devise an automatic way to bring these shares back, or at least a 1 click solution. An executable script for example.
        thanks again.

  28. I think SIP may break /mnt/NAS permissions. I’m going to try this and see if it works:
    mkdir -p /Users/Shared/mnt/NAS
    chmod 777 /Users/Shared/mnt/NAS
    Or if above does not work, try again but put “sudo” in front of above 2 commands.

  29. I also experienced the problem of the share disappearing. Inspection with the terminal reveals the share is still there and accessible, but the ownership changes to root/wheel making it inaccessible to the user via Finder or other applications.

    I filed a bug with Apple. I highly suggest others file bugs too.

  30. Thanks for the post, this has helped me automount my Synology NAS.
    However now I have the problem that if the NAS is not reachable in the network (like when I’m at the office), my “Save as” dialog in most Mac application starts hanging with the dreaded “beachball” for a very long time.
    Is there a way to set a timeout for trying to mount the network share?

  31. Anyone know what’s the quickest way to disable the changes made by the code outlined here? I’m not a programmer, but I followed everything to the tee and got this to work. Only problem now is that every time macOS boots up, I cannot launch finder for the first 2-3 minutes because this script is busy looking for the drives on my network. I don’t always want to access Finder on boot up so this is not a huge deal, but when I do, that wait is super annoying. Would appreciate some help in disabling this please.

    1. Except that this app that costs AUD$14.99 requires an additional $10.99 in app purchase to allow it to mount shares outside of the sandbox folder: /Users/xxxxx/Library/Containers/

      It is ridiculous that Automounter by Pixeleyes does not mount in /Volumes

  32. Thanks for this entry! I just got to the point, where I wanted to offload some data from my Macbook onto a USB drive, shared by the WiFi router, and you made it a painless process. You certainly made my day!

Leave a Reply to Tyler Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>