Using OSX's automounter for transparent access to remote media

The one thing that really annoys me about OSX is its network share tool-set. With Windows you can map a network share to a drive letter, check a box that says 'Reconnect at login' and you are done. In OSX the process of reconnecting to a network share is not nearly as smooth as it should be.

The easy option: using Favourites

The simpliest way of achieving this task is to add the network share as a favourite. To do so go to Finder's menu and select Go -> Connect to Server. In the window enter the type and name of the network share (i.e. cifs://server/share) and press the + button to save it as a favourite. With the favourite saved open your account preferences from the Apple Menu -> System Preferences -> Accounts and go to the Login Items tab. Now open a Finder window and browse to your user directory -> Library -> Favorites and drag the relevant share icon onto the list of login items to have it mounted every time you login.

The problem of lost connections

There is one significant drawback with this technique in that if the connection to the share is lost for some reason (e.g. through sleep mode, server or network failure) OSX will not automatically reconnect to it. This becomes a real pain when trying to use a remote share as your primary iTunes music folder because when iTunes cannot find the share it restores your music directory to its default location. This leads to confusion, missing files and if you are not careful a destroyed music library.

The good news is the automount tool can come to your aid but the bad news is it is not straightforward to setup. Automount is common among the *NIX's (i.e. Linux, BSD, etc.) and works in the background to ensure your network shares are always available after restarts and network failures.

The drawback of automount

There is a significant drawback with automount in that shares mounted using it are accessible to all users of the machine unless you get fancy with permissions. If you are sharing a desktop with people you do not trust then automount is probably not the best option for you.

Configuring automount

Note: Configuring automount requires an account with administrative privileges so either log in as your desktop's administrator or become comfortable with su'ing to the relevant user.

1. Open a Terminal window and run the following command to become the root user:

sudo sh (enter)

You will be prompted for the administrators password at this point.

Edit the hostconfig file and ensure the AUTOMOUNT option is set to -YES-

pico /etc/hostconfig

By default the automounter is enabled so in theory no change should be necessary here. If it is set to NO change it to read YES and save the file.

2. Now determine where you want the automounter to mount your network shares. In my case I created a Folder named Media in /Users/Shared.

3 . Open NetInfo Manager from the Applications/Utilities folder.

4. In NetInfo Manager create entries in the mounts directory to hold information on the shares you want automounted. To do so click on the mounts directory and select Directory -> New Subdirectory to make a new entry.

With this entry in place edit its properties so that they read like the following:

  • name = Name of entry (i.e. server:/share)
  • dir = Path to mount point (i.e. /Users/Shared/Media/share
  • vfstype = url
  • opts = url==cifs://username:password@server/share

Remember to replace placehodlers like server, share, username and password with their actual values!

Note: To add new properties to the node select Directory -> New Property from the menu.

When you are finished you should have something like the following screenshot:

Save the changes to the directory and quit NetInfo Manager if you like.

5. Now it is time to restart the automount service. Go back to the Terminal window and type:

sudo killall -HUP automount

This will stop the current automount process and begin a new one using the settings you just defined.

You should now find that by browsing to /Users/Shared/Media/ in the Finder your share has been mounted and you can browse and modify the files within.

Conclusion

Okay so setting up automount is not as simple as one would hope but you do end up with a permanent connection to your network share which makes it ideal for commonly used group resources like Music and Video shares. Hopefully it is only a short term solution and in the forthcoming release of OSX Leopard Apple addresses some (if not all) of the networking shortcomings of the Finder.