Create a Permanent SMB Mount in OSX (Updated)

Creating an permanent SMB mount in OSX is not so easy. Maybe some day Apple will make it a little bit easier, but if this is something you’re looking to do, check out the solutions below. If you have any tips, make sure to share it in the comments!

There’s a few options for creating a permanent mount in OSX so, hopefully, one of them will give you the solution. Mavericks users, please use Option 4!

Option 1

The first option is to modify the /etc/auto_master (sudo vi /etc/auto_master) file and add the following line:

/- auto_smb -nosuid

Then, I created an /etc/auto_smb (sudo vi /etc/auto_smb) file that contained the following:

/Volumes/mount_point -fstype=smbfs,soft ://user:pass@smbserver/share

Next, run the following command to give the /etc/auto_smb the proper access permissions:

sudo chmod 600 /etc/auto_smb

Finally, update your settings:

sudo automount -vc
Authenticating Through Active Directory

If you need to go through Active Directory to authenticate, use the following syntax in your /etc/auto_smb file:

/Volumes/mount_point -fstype=smbfs,soft ://DOMAIN\;user:pass@smbserver/share

Note that you’ll have to escape the semicolon (;). Also, if you’re connecting to a hidden share (i.e. a $ share), you’ll need to escape that too:

/Volumes/mount_point -fstype=smbfs,soft ://DOMAIN\;user:pass@smbserver/share\$

A few notes:

  • The soft parameter specifies OSX to not halt on failure to connect to the SMB server during boot.
  • When entering the password, it’s better to URL encode it as some special characters will cause the automount to fail silently.
  • nosuid parameter in the /etc/auto_master file prevents OSX from mounting the resource as readonly by root (see update below!).

Option 2

The second option is the vifs command. Again using the terminal type in sudo vifs and then insert the following line:

smbserver:/share /Volumes/mount_point url automounted,soft,url==cifs://user:pass@smbserver/share

Then run sudo automount -vc and then cd to your mount point and it should connect.

Option 3

This option is courtesy of a Guest commenter (thanks, whoever you are!):

  1. Connect to your network drive (finder > go > connect to server)
  2. Enter the infos for your login to your network drive and tick the ‘remember in keychain’
  3. Open system settings > users > login items
  4. Drag the icon for your network drive from your desktop to the startup items.

If you use this option, make sure you read my comment below.

Option 4 (Mavericks users)

Modify the /etc/auto_master (sudo vi /etc/auto_master) file and add the following line:

/- auto_smb -nosuid

Create a folder on your system to place your mount in:

sudo mkdir /mnt

Create an /etc/auto_smb (sudo vi /etc/auto_smb) file that contains the following:

/mnt/mount_point -fstype=smbfs,soft ://user:pass@smbserver/share

Next, run the following command to give the /etc/auto_smb the proper access permissions:

sudo chmod 600 /etc/auto_smb

Finally, update your settings:

sudo automount -vc
Authenticating Through Active Directory

If you need to go through Active Directory to authenticate, use the following syntax in your /etc/auto_smb file:

/mnt/mount_point -fstype=smbfs,soft ://DOMAIN\;user:pass@smbserver/share

Note that you’ll have to escape the semicolon (;). Also, if you’re connecting to a hidden share (i.e. a $ share), you’ll need to escape that too:

/mnt/mount_point -fstype=smbfs,soft ://DOMAIN\;user:pass@smbserver/share\$

A few notes:

  • The soft parameter specifies OSX to not halt on failure to connect to the SMB server during boot.
  • When entering the password, it’s better to URL encode it as some special characters will cause the automount to fail silently.
  • nosuid parameter in the /etc/auto_master file prevents OSX from mounting the resource as readonly by root (see update below!).

Update 04-26-2013: As a commenter indicated below, you may want to chmod the auto_smb file to 600. If you’ve run into the issue where root is the only one allowed to read/write to the mount, doing this will set the necessary permissions for the SMB share (particularly when your system reboots). I will verify this when I get the chance. Thanks Jeremy!

Update 07-01-2013: Ok, well looked into this more and I think I finally found a solution to the issue where root is the only one allowed to read/write to the mount. I first tried Jeremy’s recommendation, however, his suggestion did NOT work for me. It’s important to note that you should still chmod the auto_smb file to 600 so that the file is only readable by root. This provides an extra security layer especially if you’re specifying a password to access your SMB mount. Anyway, I really wanted to figure out a solution, so I did a little bit more research and found this link. What one user recommends is to use the -nosuid option in your auto_master file:

/- auto_smb -nosuid

Now, after you save the file, make sure you run:

sudo automount -vc

The last command is required for this to work. Once I did that and I rebooted, the SMB shares were immediately available (i.e. they were NOT owned by root)!

Update 01-13-2014: Looks like Apple has done some changes to Mavericks that affect the /Volumes folder, which will directly affect users attempting to use the above instructions. According to Alex R, Mavericks won’t allow any other folders in the /Volumes folder, for reasons unknown. The fix is to simply use a mount point at a different location. In Alex R’s case, instead of using /Volumes, try using /mnt instead. I have yet to verify this as I haven’t installed Mavericks yet but it sure looks like Alex R figured it out. Thanks Alex R!

See blogspot.com