Mac OS X: Auto mount network shares as file system

Author Johnny Josefsson on February 10, 2012 | Print | Bookmark
Instead of manually map them in Mac OS X / OS X / macOS each start up or using Bonjur Application you can use the native auto mount 'file systems'

NOTE: This requires a minimum OS version of Lion. When you send the command you should see you're NAS mounted as the specified user.

AUTO_MASTER to allow for SMB and/or AFP (does not work since macOS Sierra)

/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
# smb/cifs
# look in auto_smb and follow it completly for more mount points
/-                      auto_smb             -nosuid
# afp
# look in auto_afp..
/-                      auto_afp             -nosuid

SMB

nano /etc/auto_smb
-----------------------------------------------------------------------------------
# Purpose:         Mount HTPC Shares
# Location:        /etc/auto_smb
# Example:
#    /mount/path/pathname -fstype=smbfs,soft smb://user:password@server/sharedir
# Update mounting points (manually)
#    sudo automount -vc
###Below used in Lion, Mountain Lion, Mavericks without any issues until 2018
##/Users/htpc/Shares/dani -fstype=smbfs,soft smb://username:password@dani.domain.top/share
#
###As of 2018 switched to the one below (on Mavericks) since random failures occurs
###when it wouldn't mount all mount points
##
/Users/htpc/Shares/dani  -fstype=smbfs,soft,noowners,nosuid,rw ://htpc:passwd@dani.domain.top:/share

AFP

nano /etc/auto_afp
-----------------------------------------------------------------------------------
Section removed as it wont work since macOS Sierra

----------------------------------------------------------------------------------- This is how a good mount looks like:

ilesystem                        Size   Used  Avail Capacity  iused      ifree %iused  Mounted on
/dev/disk0s2                     233Gi   40Gi  192Gi    18% 10670128   50399312   17%   /
devfs                            182Ki  182Ki    0Bi   100%      630          0  100%   /dev
map -hosts                         0Bi    0Bi    0Bi   100%        0          0  100%   /net
map auto_home                      0Bi    0Bi    0Bi   100%        0          0  100%   /home
map auto_smb                       0Bi    0Bi    0Bi   100%        0          0  100%   /Users/htpc/Shares/dani
//htpc@dani.domain.top/share    7.2Ti  7.1Ti   67Gi   100%        0 18446744073709551615    0%   /Users/htpc/Shares/dani

-----------------------------------------------------------------------------------
This is how a good file system on the mount looks like

drwx------  1 htpc  wheel  16384 Jun  3 11:02 Barn
drwx------  1 htpc  wheel  16384 Oct 11 15:41 Bilder
drwx------  1 htpc  wheel  16384 Nov 14 11:16 Film
drwx------  1 htpc  wheel  16384 Sep  5 09:21 TV-serier

Was this article helpful?

Yes No

Category: Apple, macOS

Last updated on January 20, 2018 with 4174 views