Monday, 29 October 2007

more automounting samba drives in os x

I promised someone I'd post on this, and finally I have!

I've given up on the original method of mounting samba/cfs shares that I used to use, as it didn't really handle it well when those drives weren't available... Had to reboot to get them to remount etc, and we renamed some shares on different devices (server, NAS etc) to all be unique, so no more hassle with confusion over what is mounted at any one time.

So... I've gone with a two-prong approach:
- written a simple applescript to mount my drives where I want them
- using an app called MarcoPolo to automatically fire the script when it decides I'm at 'home'

Part 1: The script
  1. Fire up ScriptEditor
  2. Drop in the following for each drive (this example is for SMB shares):

    tell application "Finder"
    mount volume "smb://username:password@server/share"
    end tell
    end try

  3. Put in username/password/server/share as needed
  4. Repeat for each drive (if you want them to mount under the same MarcoPolo 'location')
  5. Save as an application somewhere out of the way (ie your home dir) - I used the settings in this image:

  6. Try it out - double click the new app and check it mounts everything correctly. Your system.log (available in the console app) should tell you if there's anything wrong.
  7. Add a nice icon if you want, as it will flash in your dock until the script completes.

Part 2: MarcoPolo
  1. Download MarcoPolo from the developers website, or your fav tracker site
  2. Install
  3. Set up a 'home' context - Set up whatever rules define your 'home' - for me, I've got set the IP rule (as I have a reserved IP on the router, so it's always the same when I'm connected to the home router), and also the WiFi rule, so it triggers when I connect to our home router
  4. Set up an action against your home rule to run the mount script
Note - can sometimes take a bit of experimenting with MarcoPolo to get it set up right - depends on how much info you can give it and the setup on your Mac. I've not figured out if it can rescan and decide your location on a wake from sleep, tho I've not really read a lot up on it yet.

Also, it doesn't matter if the drives are already mounted, and you try to re-mount them - smbmount doesn't mind at all :)

1 comment:

  1. I hope you will find a way to mount after waking up from sleep mode