Diskstation

Properly mounting shares in OSX

This tip is taken from information found on the website AV01D.org

Mounting shares in OSX is very easy. In Finder, click Go > Connect to Server.

Depending on whether your share is available as AFP (Apple Filing Protocol) or SMB (Samba), you enter afp://xxx.xxx.xxx.xxx or smb://xxx.xxx.xxx.xxx respectively. Replacing the xxx with the IP address of the server hosting the shares.

Click Connect and then select the shares you want to mount.

Most information on making these shares mount on startup tells you to drag the shared folders to your startup items. If you have 5 shared folders, this results in 5 open finder windows every time you reboot.

There is a much better way. First, create a folder where you want your shares to appear e.g. /Users/yourusername/Shares.

Note: the following steps require you to have superuser rights!

Open the Terminal application and edit the /etc/auto_master file:

sudo  vi /etc/auto_master

The file should look similar to this:

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

Add the following line to this file:

/Users/yourusername/Shares

So it should now look something like this:

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

Save the auto_master file and create a new file /etc/auto_afp

sudo vi /etc/auto_afp

Add a line for every share required to this file in the following format:

share_name -fstype=afp afp://username:password@host_ip/shared_folder_name

  • share_name: The name of the local folder (this is the name you’ll see in the Shares folder)
  • -fstype=afp: Use Apple Filing Protocol. This can also be set as smbfs if you require the Samba protocol.
  • username:password: The username and password you use to connect to the share
  • host_ip: Enter your server IP address (or hostname)
  • shared_folder_name: The name of the remote folder (the share name of the folder)

Now set the correct permissions for the file:

sudo chmod 600 /etc/auto_afp

And finally, restart the automount daemon:
sudo automount -vc

Your shares will automatically be mounted on every reboot, without obtrusive Finder windows.