Update NFS automounts from the terminal

If you’ve used Disk Utility1 to set up automounts — or you recently upgraded to Mountain Lion and found that the GUI for editing NFS mounts has disappeared — and find yourself needing to quickly update the records, this tip is for you.

We moved a bunch of NFS shares from one server to another over the weekend and needed to update the mount records on all clients that aren’t using our LDAP-based automount records. A handful of Macs with manually-configured NFS shares had lost access to these relocated shares. Disk Utility stores its mount records as (non-binary) plists in  /var/db/dslocal/nodes/Default/mounts. One of the lines in a mount plist contains the server:/path/to/share line for that automount.

To update the mount record, do the following using root privileges:

  1. Find the plist that contains the path you need to update in /var/db/dslocal/nodes/Default/mounts.
  2. Use your favorite text editing tool to update the path record, or replace the entire plist with one that contains the updated record.
  3. Run automount -vc to flush the cache and read in the updated information.

That’s all there is to it. I leave it as an exercise for the reader to combine all the steps into a deployable, scripted solution.


1. If you’re using OS X 10.5, it’s in Directory Utility.

Advertisements