How to automount SMB shared network drives in Mac OS X Lion

51

40

In Mac OS X 10.7 (Lion) Apple has replaced good old SMB support. Now I can't auto connect to my shared (SMB) network drives. Workarounds? Or is this impossible? In OS X Snow Leopard, I could automatically connect my Ubuntu (SMB) shared network drives with auto_smb / auto_master (autofs configuration in /private/etc/). I made three mount points (folders) directly in '/Volumes', I used /Volumes/Data and /Volumes/webroot (both SMB shared).

Unfortunately Lion doesn't connect (automount) my network drives. I have to manually connect to the server (Ubuntu file server) in Finder, then open up Terminal to navigate to the mount points, and then it connects. This is not a workable solution. I've searched (Google/SO) but found no solutions apart from an unsupported hack.

Isn't it possible anymore to automatically connect to an SMB-shared drive during startup?

cyppher

Posted 2011-09-16T13:05:55.587

Reputation: 611

Answers

50

Here's how can automount a network drive

  1. Connect to your network drive (finder > go > connect to server)

  2. Enter the credentials 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.

Source: This article

FRaccie

Posted 2011-09-16T13:05:55.587

Reputation: 501

Tested on Yosemite 10.10, works a-ok – Artur Bodera – 2014-11-13T10:15:28.283

Maybe "smb://guest:@" suppress Finder dialog. But this way doesn't mount share after unmounting. – Dmitry – 2015-10-14T10:35:02.287

It've connected only 1 share from 6. Very unstable solution. – Dmitry – 2015-10-14T12:03:37.623

Second restart - and no one share was connected. Error right by every of them. Kind became Unknown. OS X El Capitan. So it doesn't work at all. – Dmitry – 2015-10-14T12:05:45.450

6

It works :) However if you don't like having Finder popping up every time you login, you could use Automator instead: http://apple.stackexchange.com/questions/18522/mounting-shares-with-login-items-at-login-finder-windows-popup

– wildpeaks – 2012-05-24T15:03:08.267

You can hide the Finder by selecting the checkbox next to the login item. – Arne – 2013-08-06T17:43:30.340

3Checking the Hide checkbox next to the Login Items does not hide the Finder… I ended up using the Automator script suggested above and that works. – Toland H – 2014-01-19T08:31:44.420

38

sudo bash
mkdir -p /Volumes/Network/Video /Volumes/Network/Audio /Volumes/Network/Public
vi /etc/fstab

Add something like the following (1 mount per line)

192.168.0.200:/video /Volumes/Network/Video url automounted,url==smb://user:pass123@192.168.0.200/video 0 0
192.168.0.200:/music /Volumes/Network/Audio url automounted,url==smb://user:pass123@192.168.0.200/music 0 0
192.168.0.200:/public /Volumes/Network/Public url automounted,url==smb://user@192.168.0.200/public 0 0 # there is no password required for this share, just username

run automount -vc

bash-3.2# automount -vc
automount: /net updated
automount: /home updated
automount: /Volumes/Network/Audio mounted
automount: /Volumes/Network/Watch mounted
automount: /Volumes/Network/Video mounted
automount: /Volumes/Network/Public mounted

Get out of the sudo session. Browse in finder to /Volumes/Network - whenever you go there they will now just automount. Just tried this in 10.7.3 and it works fine.

If you get an authentication error like the below, it is likely that the login/password combination entered into /etc/fstab is incorrect. Make sure to rerun automount after correcting the password.

$ sudo automount -vc
automount: /net updated
automount: /home updated
automount: /Volumes/Network/Computing updated
automount: no unmounts
$ sudo ls -l /Volumes/Network/Computing/
ls: : Authentication error

Note that there is no hard requirement that the target mount point be under /Volumes/Network; you can make the target mount point be /foo, and it will be created for you upon demand.

Brookesy

Posted 2011-09-16T13:05:55.587

Reputation: 389

2Is there a way to specify default permissions for the mounted files? E.g. make the mounts readable by more than one user on a shared Mac. – Fred Clausen – 2014-12-03T03:17:23.050

@Luca "I don't like to store my passwords inside clear text files." - just make sure that /etc/fstab is readable only by root: sudo chmod 0600 /etc/fstab – Dmitry Isaev – 2015-07-27T08:27:32.010

4It doesn't show shares on the Network in the Finder. – Dmitry – 2015-10-14T12:02:48.147

1I find this a preferable solution over using Finder for two reasons: 1) it directly specifies the mounted share name and 2) takes fewer, easily automated, steps to add another share to the mix. For one or two share, Finder is barely acceptable (and only with an additional step to persist the setup) but for dozens of shares using Finder is tedious. OTOH, this solution is more 'unixy', a good thing. – pmr – 2012-06-17T13:16:35.400

1If you are trying to connect as guest, use the same steps, except that url is: cifs://guest:@192.168.0.200/music – Johnny Everson – 2012-09-29T04:52:56.707

1Be careful making changes to fstab - I ended up having to enter recovery mode and revert my changes, as my system would hang immediately after login. You have been warned. – Matt – 2012-11-08T21:46:54.200

11Is there a way to store passwords in system's keychain? I don't like to store my passwords inside clear text files. – Luca – 2013-10-12T13:42:49.253

8

Use AppleScript:

In the AppleScript editor enter this:

tell application "Finder"

try

mount volume "cifs://server/share"

end try

end tell

The save the script as an application. Add to your Login StartUp items

DJTrustGod

Posted 2011-09-16T13:05:55.587

Reputation: 81

Works perfectly. And the only one works in OS X 10.11 El Capitan. – Dmitry – 2015-10-14T12:21:05.760

1

For those (like me) wondering what CIFS is, it is a dialect of Samba (more information here https://blog.varonis.com/the-difference-between-cifs-and-smb/).

– Ashutosh Jindal – 2016-07-08T09:17:57.313

1

You can auto mount a share by dragging the mounted volume to your "Login Items" in User Accounts. That's how I do it and it's worked since 10.5.

Once caveat re SMB shares, is that with Lion the share will take about 30 seconds to mount at startup... this delay is new since Apple replaced SAMBA with their in-house implementation in Lion.

Mike W.

Posted 2011-09-16T13:05:55.587

Reputation: 11

I am aware of this workaround, however it's not what I need. The disadvantage of this option is that 2 Finder windows open automatically (even if 'hide' option is checked). In 10.6 autofs worked, mounting my Samba network drives correctly to mount points at /Volumes/... – cyppher – 2011-09-20T13:33:03.313

1

Answer: Can't do it. (OS X Lion 10.7.2)

I tried dragging mounted volumes into my "Login Items" but it just pops up an authentication error when I re-login. Yes, this used to work OK in Leopard, but after I upgraded to Lion, it stopped working.

Whenever I try to connect to my SMB shares using Finder, it gives me the same error.

I am able to mount SMB shares from the command-line, and they will also show up in Finder, once they're mounted, and Finder works just fine after that. So, as long as I go out to command-line to do the mounting, it's OK, but it won't work from "Login Items" or "Connect to Server"

Brodie

Posted 2011-09-16T13:05:55.587

Reputation: 19