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.

About these ads

About pmbuko
mac/linux geek

4 Responses to Update NFS automounts from the terminal

  1. Fede says:

    I think you mean Directory Utility and not Disk Utility.

    • pmbuko says:

      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.

  2. Eddy says:

    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

    • pmbuko says:

      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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 348 other followers

%d bloggers like this: