Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: One way to automount SMB network shares Network
Under Windows you can easily assign a drive letter to a network share, so that every time you login to your account you will have ready access to it. There appears to be no such equivalent under OS X. (You can include them in your user's Login Items list, but each share in the list will spawn a Finder window when it connects.)

I have been digging at the problem for quite some time since I switched to OS X, and I can now give you the solution I found to work the best. It is not trivial, but with the help of this screencast, it should prove rather easy.

Method 1: Using Apple Script
  1. Fire up Script Editor.
  2. Type volume mount "smb://server name/share name" for each share you want to automount. For example, volume mount "smb://nas/mp3" in my example.
  3. Test the code.
  4. Save the code as an AppleScript.
  5. Save the code as an application.
  6. Add the application to your System Accounts Login Items.
Read on for a solution using Automator...

Method 2: Using Automator
  1. Open the Finder and click on the Network icon.
  2. Click on workgroup name (maison in my example).
  3. Click on server name (nas in my example).
  4. Click on the Connect button.
  5. Take note of share names and network server name on a piece of paper.
  6. Open Automator.
  7. Click on Finder under Library section.
  8. Click and drag Get Specified Servers into rightmost screen section.
  9. Click on the + sign in the Get Specified Servers window.
  10. Type smb://server name/share name in the Address: field, and click Connect (smb://nas/mp3 in my example).
  11. Repeat the previous step for the remaining shares you wish to automount.
  12. Click and drag Connect to Servers under the Get Specified Servers section.
  13. Click the Run button to test your workflow.
  14. Save your workflow as a Workflow and Application.
  15. Add your new Application to your System Accounts Login Items.
If you need more assistance, watch the screencast at the above link.
    •    
  • Currently 2.71 / 5
  You rated: 5 / 5 (7 votes cast)
 
[99,970 views]  

10.4: One way to automount SMB network shares | 26 comments | Create New Account
Click here to return to the '10.4: One way to automount SMB network shares' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: One way to automount SMB network shares
Authored by: Raven on Feb 07, '07 07:40:03AM

Just one comment. This has been discussed over and over in the forums for over a year. I'm surprised it hasn't been included in the Hints section earier.
Have to admit though that the videos are a plus for those who are more visual.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: markhuot on Feb 07, '07 07:45:23AM

You can also just drag the volume (once mounted) to the Login Items under your account settings in System Preferences, that seems to be the easiest way I've seen and it works with all forms of volumes.



[ Reply to This | # ]
Exactly!
Authored by: stevebr on Feb 07, '07 01:12:02PM

Yes. I don't know why people always seem to forget this. Works like a charm. 15 steps is 14 too many.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: nickfitz on Feb 08, '07 08:33:54AM

Maybe that's why the article says

You can include them in your user's Login Items list, but each share in the list will spawn a Finder window when it connects.

Clearly the whole point of the hint is to have the share mounted without spawning a new window.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: kaltekar on Feb 07, '07 08:11:58AM

Or you could just drag an alias to the share into the startup items and it will accomplish the same thing. Only you won't have to test a script :)



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: operator207 on Feb 07, '07 08:18:02AM

Maybe this will help some, being that if the share is mounted, you still have to click on the icon to open the finder window.

I use my PB at work and home, I have shares I connect to on my home internal network that I do not need access to at work and vice versa.
This is how I do it:

1. Mount your share the way you normally do.
2. Create an alias for that icon on the desktop. (cmd+click: create alias)
3. When you reboot, and need that share, you just click on it.

I keep my aliases in a folder on the desktop (I have a lot of shares at work), and when I need a share, I open the folder and click on the icon. Has worked great for me. And for those of you that are in the same boat as I am, but do not want to goto finder: go: connect to server, for every connection every day you need it, maybe this will help you out too.

BTW, the above, I believe I got that from a post here somewhere ~2005



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: beepotato on Feb 07, '07 10:19:45AM

Indeed, I think aliases are the best (and easiest) solution if you don't absolutely need your shares to be automatically mounted at login but you just want easy access to them.

It seems a lot of people who are new to MacOS don't know about this and how useful aliases can be, so it is worth repeating it.

It's also worth mentioning that you can also create an alias directly to a folder somewhere deep in the hierarchy of a network share. When you later open the alias, the share will automatically mount and you will be taken directly to this folder, which gives you even faster access.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: lar3ry on Feb 07, '07 10:47:22AM

I do something similar, only I put the aliases into Favorites, which is my default Finder window. If I need something mounted, double-click and I'm set.

I try not to use the Desktop, except for transitory things, and for a "bucket" folder that I call "Stuff," which I clean out every few weeks.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: rjbailey on Feb 07, '07 09:13:09PM

I put the aliases in a folder somewhere in my home directory, then put that folder in the Dock. A right-click on the folder and I can select any share to mount.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: taxi on Feb 09, '07 04:56:30AM

I've gone one step further. I've removed Network Drives from my desktop, and placed an alias to each of the drives I mount instead. Then I can double-click, drag-n-drop or otherwise onto any of these.

I still use a script (similar to the one above) for mounting one share, which is where my iTunes library lives.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: mm2270 on Feb 07, '07 08:22:29AM
I've been using scripts like this for years now for our Macs to connect to server shares, both AFP and SMB. I find it stupid that Apple doesn't give OS X users an easy way to add auto mounts. It can be done quite nicely in an Open Directory system with managed accounts though. But not with a stand alone OS X system.

The AS solution is easier to work with than the Automator workflow primarily because the Automator one doesn't allow you to edit the URL paths after you've added them. You essentially have to remove it and add it back in. Retarded!
Also note that if the share you're connecting to requires authentication you'll need to include that in the code to get true auto-mount behavior (or it will ask for authentication when it attempts to mount). Such as:

mount volume "smb://username:password@server_address/share"

[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: archdata on Feb 07, '07 08:27:02AM

I found that the easiest method is to go the Automator way. I have several Automator actions that will mount and unmount my shares. I installed the Automator plugin for quicksilver and now all I need to do is invoke quicksilver and launch my actions.

When I get to work I launch "Mount Work Shares" and when I leave for the day I run "Unmount Work Shares". I have similar actions set up for when I get home.

I prefer not to have my shares mount automatically as I don't always need them. I have also set up individual actions for just certain drives - as sometimes I just need one share not all 20 of them.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: beepotato on Feb 07, '07 10:11:14AM

If you don't always need your shares, it seems that the solution of using aliases might be better for you (see operator207's comment above).



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: Schwie on Feb 07, '07 08:42:34AM
Not to pour cold water on this, but this information doesn't work very well for people with MacBooks and PowerBooks who frequently switch locations where these shares may or may not be available. For instance, if you're at the office and mount the share, but then leave to go home and you don't unmount these shares, they persist when you arrive at home and hang your Mac. Its a major oversight in OS X and how it handles network volumes.

In addition, its very rare that my MacBook Pro is "shut down" when I arrive at work each day. Usually, its sleeping, and this script does not help.

There is a hint for sleeping and mounting here:

[link:]http://www.macosxhints.com/article.php?story=20061224140933809&query=sleep%2Bshare%2Bsmb

but in our testing, it just doesn't work very well. There's got to be a better solution out there!!!

[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: codingismy11to7 on Feb 07, '07 09:11:15AM

Same with my Macbook Pro.

So...I wrote a Python script that is run every 2 minutes (or maybe every minute, i can't remember). It has a list of shares and mountpoints. If they're mounted, the script exits. If not, then it pings the hosts. If they're up, it then mounts the shares.

Yeah, apple needs to do some work in this area, you shouldn't have to have a CS degree to have automounted shares on portable machines.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: algernon on Feb 07, '07 09:14:04AM
Automounting Sharepoints at Startup:

http://www.bombich.com/mactips/automount.html

I have a share at home and two at work mounting dynamically. I just have to remember not to try to access one of the other from the wrong place - it hangs the Finder, but not for very long. Otherwise this works great.

[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: taxi on Feb 09, '07 05:00:53AM

Not for SMB shares, unfortunately.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: markflo on Feb 09, '07 07:44:02AM

All you gotta do for a graceful exit on failure (due to the shares not being available) is add a "try" statement to the script, like this:

try
mount volume "smb://user:pass@smbserver.lan/share"
end try

Simple.

(you might need to wrap that in a 'tell application "Finder"' statement, though)



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: chphilli on Feb 07, '07 09:20:19AM

A method similar to what I'm doing has been shown already, but I'll show what I have, since it seems to work really well for me:

First off, my laptop is almost never turned off - and I almost never log out, so the login items trick isn't that useful to me. However, the laptop does go to sleep whenever I close the lid, so that immediately points me to SleepWatcher.

SleepWatcher allows you to use two scripts, one for on sleeping, and one for on waking up.

If you create the automator workflow as described in the hint above, and then add it to sleepwatchers wakeup script, it will attempt to connect everytime your laptop wakes up. Just add something like "open ~/connectToMyServers.app" to the script.

Then, I add something like "umount /Volumes/SERVER_NAME" for each server that I have in the automator workflow to sleepwatcher's sleep script.

This removes the hassle of having connected drives when you go off network ( assuming you sleep when you move your machine ), and reconnects to the servers if they are available.

I'm sure there is a better way of managing it ( could use automator to manage the disconnects too I'm sure ), but this is working really well for me right now.

[ Reply to This | # ]

10.4: One way to automount SMB network shares
Authored by: neill on Feb 07, '07 11:06:32AM

I've been using a similar method to this for years to mount an afp server volume on my laptop at home . . .my wife and I save all real data to the server instead of our local homedirectories. An applescript of the form mount vol afp://user:password@server_IP:sharename works perfectly.

Recently I reorganized my backup routines for the laptops . . .and created a second share on the server with identical share permissions as the original . . .call them share1 and share2.

I'm running into an issue when the second script is run . . .what I want to do is keep share1 always mounted and only mount share2 when needed for the backup. Running the script is easy . . .but the problem occurs when it is run.

If share1 is already mounted and I run the script to mount share2 . . .I get some random combination of the following: (a) an error dialog that says Disk some volume can't be found with an OK and Edit button, (b) proper operation of the script with share2 mounting normally or (c) same as #1 except the volume mounts when I click the OK button. Clicking the Edit button in either (a) or (c) gives me an error that says Script Editor can't open the dictionary of the application because it is not scriptable.

Both scripts are saved as universal binary application bundles.

Both scripts work properly if neither volume is currently mounted when they are run.

If I mount share2 then run the script for share1 . . the same scenarios as (a) through (c) above occur.

Both shares are shared via SharePoints on a G4 running Tiger (non server version). Permissions are assigned as follows: Owner = admin user on the G4, Group=shareusers with R/W, and everybody=R/W. Shareusers is a group created via SharePoints that has a single user in it. The user is a server non admin account.

Both scripts are run with the userid/password correspoding to the single user in the shareusers group.

Any idea what might be going on . . .or how to get the second volume to mount correctly consistently?



[ Reply to This | # ]
umount /Volumes/SERVER_NAME
Authored by: airdrummer on Feb 08, '07 07:54:26AM

the problem i've got is that i have several nfs mounts on the same server, so the 1st mounted is named /Volumes/serverName, the 2nd is /Volumes/serverName-1, etc: order-dependent:-P

makes problems for logical links...



[ Reply to This | # ]
umount /Volumes/SERVER_NAME
Authored by: lucious1242 on Jun 07, '07 09:02:31PM

I'm getting this problem too, anybody got any idea how to resolve?



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: unimatrixzxero on Feb 10, '07 02:49:59AM

I've tried to apply this tip with AFP Volumes that are password protected. This isn't any form of automount for me since now it would ask me for my username and password every time I log in. The method of just dragging the volume on my startup objects works better since KeyChain Access uses my stored password there and doesn't make me confirm the mount every log in.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: drm0223 on May 05, '07 08:22:59AM

I have no luck using 'mount volume' in AScript or using Automator to mount an nfs:// or cifs:// volume. This is the volume type WesternDigital NetCenter uses with it's Shared Volumes. I can use their utility and I can mount the volume using the Finder's Go/Connect To Server menu, as well as double click on an alias.

In AScript I get a network file permission error when trying to mount the nfs:// format, both w and w/o including my username and pw in the 'mount volume' command, and an error of type -36 when trying to mount the cifs:// format.

I would like to be able to script this or use Automator and welcome any suggestions.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: prickeke on Mar 04, '08 10:47:55PM

The instructions read:
volume mount "smb://server name/share name"

I just received a new macbook with OS X 10.5.2 on it. I was unable to execute this script. I had to change to this:
mount volume "smb://server name/share name"

Your mileage may vary.



[ Reply to This | # ]
10.4: One way to automount SMB network shares
Authored by: xylo on Nov 07, '10 02:46:13AM

Why complicate your life?

Use earlier AutomountMaker



[ Reply to This | # ]