Friday, January 29, 2010

Auto Mount NFS Shares via Bonjour

07/21/2011 - Update
It papers this site is no longer available.  As such I have posted the original script here and the automated workflow is  here.

There are also installation instructions for OSX 10.7 which is working but requires some extra setup and Xcode must also be installed before the scripts.

  • Download the two file above and extract them someplace.
  • Drag the Automator action into our Applications folder and add it to your user accounts Login Items list so that it will automatically run each login.
  • Setup the background script to do the actual work.
Open up the Terminal application and locate the directory you saved the script into.
cd ~/Downloads

Run the following commands to install the script locally.
sudo mkdir -p /usr/local/bin
sudo cp bonjournfsmd.rb /usr/local/bin/bonjournfsmd.rb
sudo chown root:wheel /usr/local/bin/bonjournfsmd.rb
sudo chmod +x /usr/local/bin/bonjournfsmd.rb

Run the following commands to install some dependancies required on OSX 10.7 only.
sudo gem install dnssd
sudo gem install daemons

A wile back I switched my server over to FreeBSD/ZFS and ended up changing the shared volumes to use the NFS features of ZFS.
There were a few minor issues with the initial configuration and the OSX clients but this was not to difficult to resolve. Specifically the NFS system does not allow for user account mapping, but rather the accounts on both the server and client must be identical. Furthermore this mapping is not done by username, but rather by the UID of each user. On OSX the UID start at 501 where as on FreeBSD they default to 1000. The best approach to fix this problem is simply to update the account on the BSD box to use the same UID as OSX. (It is possible to change UID in OSX but not recommended.) After this fix everything was working correctly including write access and ACL lists.
The other thing I wanted to do, and the reason for this post, was to have my OSX desktop automatically map these volumes on boot. I found a simple Bonjour NFS share Mounter Daemon,, that can be run from the terminal and will do exactly that but I was unable to get the script to run at boot. In the end I had to create a Automator application to run the script and then add that application to my startup items.
You can download the Application with the above auto-mount script embedded in it here.

1 comment:

lauren said...

As you provided very well written installation instructions for OSX.And you mentioned that Xcode need to be installed first.Can you explain why is it so?
digital certificates