Mounting NAS Volumes in Mac OS X the Right Way

I’ve been using Mac OS X for a while now, but upgraded to a 13-inch Macbook Pro Retina about a year ago.  I love having access to the command line and I just RDP when I need to do anything on a Windows machine at work.  I often find myself needing to access my NAS and networking is one of the only features of OS X to which I have had trouble adapting.  On my Ubuntu laptop, it is effortless to mount a network drive and access it like a local disk or path, but that is not the case on my Mac.  Time and time again, I have to re-establish my connections to the NAS, which is time consuming.

Other articles instruct users to mount the volumes and add those volumes to Login Items for automatic mounting.  I wanted a solution more closely aligned to editing fstab.  After a bit of trial and error and searching the web, I came across this article.

My original idea was to mount my NAS to a folder in /Volumes.  This was problematic due to weird permission issues and automatic folder removal after a reboot.  I finally realized that for better integration into my normal workflow, I would be far better off mounting the NAS to my home directory in /Users/<account>/.  I also found that using AFP (Apple Filing Protocol) gave me better performance than CIFS/SMB.  I am using AFP in my example, but if you want to use another protocol, the steps are very similar.

My NAS is a Seagate GoFlex Home, so I created /Users/brandon/GoFlex as myself.  Then I followed the steps outlined by bmorganthaler on the Apple Discussions website.

From a terminal window:

$ sudo touch /etc/auto_afp
$ sudo chmod 600 /etc/auto_afp

Open the auto_afp file with vi to add the necessary lines.

$ sudo vi /etc/auto_afp

If you are unfamiliar with vi, once it launches, type i to get into insert mode and enter the following, edited to your needs: (local_mountpoint)     -fstype=afp     afp://(username):(password)@(hostname)/(share). For example:

/Users/brandon/GoFlex     -fstype=afp    afp://brandon:[email protected]/brandon

Hit esc to get out of insert mode, type :wq to save and exit. Now we have to configure the system to call the new auto_afp configuration we created.

$ sudo vi /etc/auto_master

Add the following line using the vi techniques outlined above.

/-                      auto_afp        -nosuid

Save & quit, then restart the automount process to mount the new path(s).

$ sudo automount -vc

Verify that your path is mounted an accessible and reboot just to make sure it mounts as expected.

That’s pretty much it!  You now have the mounts you always dreamed of having.  I was able to add some of my media folders to my Favorites bar for quick access, something I was not able to do when I had the mount point located in /Volumes.  I was lucky that my NAS supported AFP, but if you have to use SMB, just replace the AFP names with SMB and I think you should be set — although I haven’t tested it.

Brandon has worked in IT for nearly 20 years, and currently serves as a SQL Server DBA for a healthcare company in California. In his spare time, he runs for miles and helps maintain RealCajunRecipes.com. Brandon is a certified SQL Server administrator.

Posted in OS X & iPhone
18 comments on “Mounting NAS Volumes in Mac OS X the Right Way
  1. Ben says:

    Ho-leee crap, this is one of the things I've struggled with since throwing OSX into the Windows/Linux mix at home. My Windows 7 Media Center HTPC is also the file server and I'm used to the "just works" ease and stability of mounting network drives or adding them to the fstab. I tried the Login Items route and while that kinda works, it's a pain when the connection is lost – frequently and seemingly at random. You method has given me the fstab-like functionality I need!

  2. Jeff says:

    I’ve tried to follow this but can’t get it to work…doesn’t mount the NAS folders that I need

    /etc/auto_afp

    /Users/NASmount/NAS/PhotoServer -fstype=afp,soft afp://username:[email protected]/NAS/PhotoServer
    /Users/NASmount/NAS/TimeMachine -fstype=afp,soft afp://username:[email protected]/NAS/TimeMachine
    /Users/NASmount/NAS/MusicServer -fstype=afp,soft afp://username:[email protected]/NAS/MusicServer

    from /etc/auto_master

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

  3. Tomas R. says:

    Hello. Nice article, I will definitely will be trying to set it up.

    BUT: Is there a way so I don’t have to write plain-form user passwords to the /etc/auto_afp file?

    Thanks,
    Tomas

  4. Craig says:

    Well this seems to have worked for me, after spending a couple of years trying to find a Windows-like solution.

    I have no knowledge of Terminal, I just followed the instructions and substituted what I needed to. I rebooted and my NAS was mounted!! So much better than the crappy log-in way of doing things.

    Thanks!!

  5. Craig says:

    BTW, I also used SMB rather than AFP, so I can confirm that works as well.

  6. Craig says:

    Perhaps, I was wrong… I removed the NAS from the log in options and rebooted – the NAS didn’t mount… I’ve placed the NAS back in to the log in, rebooted , and it mounts again.

    What is different is the NAS is mounted straight away, rather than having to wait for several seconds and getting numerous warnings that the NAS could not be mounted, so there is some improvement there.

  7. Gilles St-Onge says:

    It mount the drive but I always get this kind of permissions
    drwx—— 1 Administrateur wheel 568 17 Oct 15:58 MacHomes

    I try to change it, but no way… The user/password for the mount, have all access to this share

    So my concern, is that I need to be able to write in this folder, even if do:
    sudo chmod 777 MacHomes, I not change

    Any ideas ???

  8. Ravel says:

    I have the same issue like Gilles St-Onge. I get the auto mount to work. No problem. But there are 4 users on our mac who would like to access the data on the NAS. We use fast user switching.

    Every time, one user accesses the data, the rights of the mount are restricted to this user. Is there any trick to set the access rights so that all users have access to the mounted volume?

  9. Oliver M. says:

    I often having problem in NAS. Good to know that you mention about external drive. Perhaps I should make it on my external drive.

  10. Andreas Irestål says:

    I’ve had the same issues with permissions as already mentioned by a few. These issues were solved by adding the noowners option in auto_master. Mine looks like this

    /- auto_afp -nosuid,noowners

    Could be helpful to a few ppl out there on the interwebz =)

  11. Jarred says:

    I am trying to get this to work. I am following all steps and when I get to the last bit: Sudo automount -vc. I get this error: dir afp://username:[email protected]/Jarred must start with ‘/’

    • enderless says:

      Read the error. “must start with ‘/'”

      The first parameter should be the full path to the directory you want to mount, i.e.:

      /Users/Jarred/dir afp://usernam….

  12. Matt Child says:

    Almost works perfectly. I tried mounting the directory /volumes/ it appears but then does not show under devices any idea how to make it almost perform like a manually mounted drive or external drive?

  13. Gunnar says:

    Hi! It works like a charm in my network. But when i´m not at home, the finder doesn`t react for minutes, because he wants to mount the folders and can`t get it.
    Is there a way to use the script only, when i`m at home or when i`m in a specific network or when i get an specific IP?

  14. Bryan says:

    I followed the instructions exactly, and it does mount after reboot, BUT I’m getting this message:

    “The folder “iKho” can’t be opened because you don’t have permission to see its contents.”

    When I go back into terminal, this is the permissions I see on the mount point:

    drwx—— 1 root wheel 806 May 17 01:45 iKho

    Running sudo chown, chgrp or chmod to try to gain ownership of it, all fail with “Operation not permitted”.

    Anything else I can do about this? I’m using the afp as described.

  15. Dan Power says:

    Hi, great article and easy as to follow, but I’m also having the same problem, I was getting an error with Carbon Copy Cloner that my NAS volumes aren’t mounted via AFP and therefore don’t support sparsebundles. I’ve mounted a “Backup” folder on the NAS to my home dir using this method and it seems to have worked, but CCC now gives me an error saying that I don’t have permission to write to the folder. I can’t create a folder or move a file there.

    Any assistance would be appreciated as this NAS was bought to be a backup station and if I can’t get that to work then I’ve got a $1000 doorstop :)

    Thanks

  16. John says:

    For folks having permissions issues, make sure you create the folder you’re mounting to manually as the user you want to have access *first* (before mounting), then mount it.

    If you’ve already mounted it and can’t access then just do this:
    1) sudo umount
    2) sudo rmdir
    3) mkdir
    4) sudo automount -vc

    Hope that helps!

  17. Brent says:

    Weird,

    This is what I’ve done:
    /Users/name_of_mac_mini -fstype=afp afp://user:[email protected]/video

    But now my mac mini is doing the 3/4 boot thing where it just hangs. Seems I cannot remote into it anymore to safe boot…

    Any Ideas what I may have done?
    Thanks, I appreciate your help

Leave a Reply

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

*