Data Management

Mounting NFS volumes in OS X

Vincent Danen outlines the steps to set up NFS mounts with the Disk Utility GUI in Mac OS X and offers some basic tips on configuration.

Vincent Danen outlines the steps to set up NFS mounts with the Disk Utility GUI in Mac OS X and offers some basic tips on configuration.

---------------------------------------------------------------------------------------

Mac OS X, being a UNIX-based operating system, can handle a number of file sharing protocols. It supports AFP, SMB, FTP, and NFS out of the box. For Mac-to-Mac file sharing, AFP is the best solution. For interoperation with Windows, SMB is best. For sharing files with Linux or other UNIX servers, using NFS is a great solution, but getting OS X set up as an NFS client can take a little trial and error.

With OS X 10.6, there are two ways to have your Mac set up as an NFS client. The first is to use the built-in automount setup, which allows you to automatically connect to hosts by accessing /net/[hostname]/, but this can be problematic. This uses the automountd daemon which is configured using the /etc/autofs.conf and /etc/auto_master configuration files.

For those familiar with UNIX, or in environments with a lot of regularly-accessed NFS mounts, it would be worth exploring setting up NFS mounts this way, but I have found it to be quite frustrating. Instead, use the Disk Utility GUI to set up individual NFS mounts. It is easier to configure, but becomes painful if there are a lot of NFS mounts to set up, as you must do them one by one.

To set up NFS this way:

1.      Launch the Disk Utility application. In the menu bar, select File | NFS Mounts. A new window will open that lists any defined NFS mounts.

2.      Select the "+" button at the bottom left of the window to add a new NFS mount.

3.      For the remote NFS URL, use nfs://[hostname]/[export]; for example: nfs://fileserver.mydomain.com/srv.

4.      For the local mount location, use something like /nfs/fileserver.

5.      Expand the Advanced Mount Parameters section. Here you can pass some extra parameters to the NFS mount. The ideal value to place here is: resvport,nolocks,locallocks,intr,soft,wsize=32768,rsize=3276 (Look at the mount_nfs manpage for all of the available options and what they mean).

6.      Click the Verify button and OS X will initiate a connection to the NFS server to make sure the settings are correct. When done, click Save.

Figure A

At this point, you can navigate to /nfs/fileserver/ in the Terminal to deal with files, or you can use the Finder. The Finder won't list these mounts like it does AFP or SMB; they won't be listed under the SHARED section of the Finder sidebar. You can use the Finder to navigate to the path by going to the root device (i.e., the default Macintosh HD) and then opening the nfs folder, or wherever you specified the local mount. Any available NFS mounts will be noted there, and you can navigate the directory tree that way.

The nice thing about defining NFS mounts is that they are always available, because they are auto-mounted. So when you reboot the computer and then navigate to the defined folder, OS X will automatically initiate a connection to the NFS server.

Server-side, there is one important thing to note. There is a known issue with OS X where you must pass the insecure option to the defined host in the server's /etc/exportfs configuration file:

/srv client.mydomain.com(rw,insecure)

NFS client support in OS X is not nearly as nice to set up or as graceful to use as it is on a Linux client, but it works well enough if you configure it properly. The key is the advanced mount options; without those options, setting up OS X as an NFS client will be more painful than it needs to be. But with them in place, using NFS on OS X can work quite well, and the always-available capabilities of the automounter are really handy.

About

Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.

9 comments
CÃ
CÃ

Hi all, I'm looking for a solution regarding the refresh problem on Lion OS with the nfs volumes. I am configuring a system with a GBLabs NAS and 3 Mac clients, Lion and Snow Leopard, and everything is working correctly with the Leopard but the Lions are not refreshing the information when renaming files or folders. Do you know if this is being fixed with Mountain Lion or any other way to solve it? Best regards, C├ęsar

rreco
rreco

i am trying this with openindiana. the max speed i get is ~20mb/sec... any idea how to increase this? i am on a gigabit ethernet network.

alexbfree
alexbfree

Hi, this is a great article but can you provide a little more info about what you meant by "The key is the advanced mount options; without those options, setting up OS X as an NFS client will be more painful than it needs to be." I know I can read the man page to get lots of specifics, just looking for a high level overview of what "pains" you were referring to. Also, do you know if there is a way to create drive shortcuts for mounted NFS drives in OSX? Thanks Alex

khdetw
khdetw

Any way to set this up from the command line? The benefits of doing it that way are obvious to anyone who administers more than one machine. And even for one machine it's a lot easier to document and repeat (if necessary) what you did.

rlhamil
rlhamil

"intr" is typically not relevant with "soft". "soft" means that an unresponsive server causes an error on the client, which may cause problems with memory-mapped I/O (including executables) or with programs that don't bother to check for I/O errors. The opposite of "soft" is "hard", which means the client keeps trying until the server comes back up. Together with "hard", "intr" means that it's possible to kill a program that's waiting for the server to respond. Since "soft" can cause data loss, and cause processes running NFS mounted executables to die if the server becomes unresponsive, "hard,intr" is almost always a better choice. If you nevertheless have some reason to favor "soft" mounts, I'd be interested in hearing it.

another_rob
another_rob

When you say "rsize=3276" do mean "rsize=32768" ??? If so, could we then just say "rwsize=32768" Could you please give some reasoning behind upping this from the default?

maclovin
maclovin

Finder 'Go' Menu 'Connect to server' nfs://server/share How the hell hard is that?!

vdanen
vdanen

What are you connecting to? Over here, connecting to Linux servers, it is not nearly this easy. I wish it were. Using Finder like this does not allow you to set the mount options that seem to make all the difference.

maclovin
maclovin

If you are using some other protocol than AFP, then you need to specify it. When you just type in the address/IP of the server, the connect to dialog ASSUMES the AFP protocol. However, if you put 'nfs://' or 'smb://', that should give you the shares after specifying your login details. Say the server's IP is 172.0.0.10. Go>Connect to Server... The put in "smb://172.0.0.10" Then it asks for the login details, and will then give you the list of shares you have access to just like normal with an AFP (Apple Filing Protocol) server. Any linux server that hosts machines other than linux workstations SHOULD have SMB enabled, and Macs can connect to those shares. Sorry for the late response!