Automounting AFP and SMB volumes on Mac OS X

Of all the things to spend a couple hours figuring out... All I wanted to do was to have certain shares mount upon login. Who knew that it would be so complicated in Mac OS X?

Here are a few methods I investigated:

1. Create alias of shared volume and drag into Login Items

I harrassed Victor A. for a long time, and he suggested this one. Unfortunately, it doesn't work.

2. NetInfo entry

I tried following some directions I found online, but I had no luck mounting my AFP share. A dynamically mounted share sounds ideal because I would really much rather have the share mount itself only when accessed... but the point was moot because I couldn't get anything to work.

3. Shell scripts

I created shell scripts like this:

#!/bin/tcsh -f

# mount afp volume mkdir /Volumes/sharename mount -t afp afp://username:password@192.168.x.xx/sharename /Volumes/sharename

# mount smb volume mkdir /Volumes/sharename2 mount_smbfs //myserver/sharename2 /Volumes/sharename2

# mount 2nd smb volume mkdir /Volumes/sharename3 mount_smbfs //myserver/sharename3 /Volumes/sharename3

I then used LoginWindow Manager to get the shell script to run upon login and logout, and the following is what happened:

  1. The AFP volume mounted, and the first SMB volume mounted. The second SMB volume did not mount.
  2. I got the dreaded "mount_afp: the mount flags are 0000 the altflags are 0020" message upon mounting the AFP volume. Yippee.
  3. All volumes were mounted with root:unknown ownership, which was also the ownership of every file and folder within.
  4. The AFP volume was read-only even to my user account, despite the bizarre root:unknown ownership. SMB volumes were unreadable without sudo.

Lame, and not useful.

4. fstab

I am an fstab moron, and couldn 't find any examples of configuring it to mount AFP/SMB. I'm not sure if it's even possible.

5. Jean-Michel Marino's AutomountMaker program (it works!!)

This just worked, and I wish I had tried it first instead of trying to be fancy. I created scripts with AutomountMaker and dumped them into my Login Items list in the Accounts system prefs.

--- So there you go. Anyone have fancier ways of doing this? :)