MacOS – Mount network share (AFP/SMB) for multiple users (fast user switching)

afpmacosmountnassmb

i'm having the following problem with my network shares from my NAS (Synology 415+ if it matters) in Yosemite.

At home, we have an iMac with two different users. I moved all of our media (music & photos) to the NAS, so that both users could use the data with the according apps.
I thought, that it would be easy to mount the network shares for both users, but actually it isn't – or i'm doing something wrong.

I'm using a simple Applescript in the following form

tell application "Finder"
    activate
    mount volume "smb://ipaddress/sharename/"
end tell

that is started automatically when my user logs into the system.

That works fine for me. But when my partner switches to her user account, the mounts aren't accessible for her. Moreover, when she starts the same script as i do, the paths are getting messed up:

If two users mount the network shares, two different folders exist on the system: /Volumes/music for the first user and /Volumes/music-1 for the second user, which messes up all file paths (especially in iTunes, but also in Lightroom or other apps).

Is there ANY way to mount a network share for both users? I really don't care if i use AFP or SMB, i just want a network share which is usable for multiple users. Seems like a common scenario for me.

Best Answer

  1. Setup your NAS to export a NFS-share. Refer to the Synology knowledgebase how to do this or use the following how-to to set it up, fine tune and secure your set-up.

    You may do it manually in the command line also:
    Let's assume your media folder is /Shares/Media. Create or edit a file named exports in /etc. The example below restricts the access to computers with an IP address in the range 192.168.0.1 - 192.168.0.254. You may have to restart your NAS or at least nfsd (nfs-daemon).

    Linux/NAS file /etc/exports:

    /Shares/Media 192.168.0.0/255.255.255.0(rw)
    

    if you use a Mac Server use this line:

    /Shares/Media -network 192.168.0.0 -mask 255.255.255.0
    
  2. Edit /etc/auto_master on your Mac and add the line:

    /-                                  auto_media
    

    file /etc/auto_master:

    #
    # Automounter master map
    #
    +auto_master                        # Use directory service
    /-                                  auto_media
    /net                                -hosts      -nobrowse,hidefromfinder,nosuid
    /home                               auto_home   -nobrowse,hidefromfinder
    /Network/Servers                    -fstab
    /-                                  -static
    
  3. and create a new file auto_media in /etc on your Mac

    file /etc/auto_media:

    /Media         IP-NAS:/Shares/Media
    
  4. Please don't forget: all files mentioned above need a trailing empty line

  5. enter sudo automount -vc in Terminal on your Mac with the output:

    $ sudo automount -vc
    automount: /Media updated  
    automount: /net updated  
    automount: /home updated  
    automount: no unmounts  
    

/Media will now always be visible in the root folder of your Mac and accessible for both of you as long as the NAS is up & running. No Apple Script to mount it nor a Connect to Server needed.

(Set up and tested on a Server 10.7 (no Synology NAS, because i don't own one, but it shouldn't make a difference) and Client 10.9)