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

5 thoughts on “Update NFS automounts from the terminal

    • For 10.6 and 10.7 (I use 10.7 now), the NFS Mounts GUI is in Disk Utility. It was in Directory Utility in 10.5. The GUI interface is completely gone in 10.8. I updated the post for clarity, though, so thanks for your comment.

  1. Is this “more” correct than editing /etc/auto_master? I added this line to that file:

    /- /etc/automounts/nfs

    and then created the /etc/automounts/nfs file with contents like this:

    /nfs/server1 -fstype=nfs,ro,resvport,bg,hard,intr,tcp server1:/data1
    /nfs/server2 -fstype=nfs,ro,resvport,bg,hard,intr,tcp server2:/data2

    and then ran:

    sudo automount -cv

    • No more or less correct. If you use the /etc/automounts method I blogged about recently, then you need to edit those files. OS X only stores mount records in dslocal plist files if you’ve used the GUI to add the mounts.

  2. on 10.8, I see that the plists at /var/db/dslocal/nodes/Default/mounts are actually binary plists, but under 10.6 they appear to be regular text plists.

    also, how is the generateduid in the plists calculated? (they appear to be unique on each machine that I have checked)

    I assume I can’t just push out a

Comments are closed.