How to configure an NFS share from Mac OSX to Linux
What is NFS and why would I want it?
Network File System is a distributed file system protocol that allows you to share files across a network. You can share a folder or an entire drive, and a user on another machine will see a normal shared drive and be able to use the files as if they were on the local drive. This can be useful if you have a NAS or some other remote server, or if you're running a VM that doesn't have built-in file sharing.
Update - February 2017
I wrote this back in 2007 when Parallels on Mac didn't have a file sharing facility, and there was no Dropbox. The solution was to install NFS and set up a shared folder, which you could do with some free downloads and a bit of tweaking. Parallels and macOS have changed a lot since those days (for one thing, the Mac's firewall is now off by default), but I'm keeping this guide in case it's useful to somebody.
The NFS server runs in the background on the host Mac, publishing the list of available files and listening for requests from the client (Linux in this case, but could be anything). You can configure the number of processes you want to have running. When the client interacts with files, the server process will handle the read and write requests (similar to what a web server does when you click on a link). When you set up an NFS share, you specify what directory you want to make available and with what permissions - for example, you might make it read-only. I have an external Firewire drive and I want to make that available to any user account within the Linux VM. In the steps below I'll therefore be referring to /Volumes/Firewire1, but you can substitute any other path such as /Users.
Another popular NFS configuration is to have your home directory automatically follow you, so for example if I log into Linux as "william" and I have a corresponding account on the Mac (with a matching ID rather than account name), I could have it mount my Mac home directory as /home/william. This should be possible here but I won't be using this approach. For one thing I couldn't get it to work, but also I realised it wasn't what I wanted anyway. The discussion I had with an extremely helpful poster on the Parallels forum is here.
Set up the NFS share
Download NFS Manager from www.bresink.com/products.html. It's very low-cost shareware but you can use it free if you don't mind an occasional pop-up reminder. You could probably set things up without NFS Manager, but it makes things a heck of a lot simpler.
Using NFS Manager, add a new share, browsing for the directory you want to make available - in my case that's /Volumes/Firewire1. Use the option to allow only specified computers access (depending on your network connection it might not be possible for random hackers to mount your hard drive remotely, but it's best to be safe). Use the IP address you assigned to the Linux VM, in my example that is 10.0.1.100. You'll need to hit the "Activate" button iback on the main screen to start the actual processes running.
Configure the Mac's firewall
In recent macOS releases, the firewall is off by default), so unless you have explicitly enabled it, this section about opening ports is no longer relevant.
The NFS protocol uses ports 2049 and 111,2 2049 is for the NFS daemon itself, while 111 is used by "portmapper", part of the remote procedure call mechanism. and the Mac's built-in firewall blocks these by default. Open "System Preferences, Sharing", and go to the "Firewall" tab. You will see a list of network services that you can click on to enable or disable access - however, NFS is not on the list. Hit "New..." and select "Other" from the dropdown list. In the TCP Port Number(s) field enter "2049,111". Enter a description such as "NFS", and click OK.
Set up the client side
Before making any changes to your Linux VM, take a backup (or in Parallels Desktop version 3, create a snapshot).
Now in Linux as root, create the directory to use for the share. I'm going to call it "extdrive", so I'll enter mkdir /extdrive. Next edit the file /etc/fstab (filesystem table), adding an entry like this (I'm using my external drive example - substitute your own details for IP address and path:
10.0.1.2:/Volumes/Firewire1 /extdrive nfs(Confirm that Linux can see the host by pinging the specified IP address, e.g. by entering ping 10.0.1.2 on the command line.) There are other fields for entering more information, but I'm cheating somewhat by letting them all use their system defaults. (However, from checking man nfs it seems the defaults are all pretty sensible, for example if you don't set explicit read and write packet sizes, client and server negotiate to find the optimal size both can handle.)
Now reboot Linux to make sure it worked. What you should see when you log back in is directory called "/extdrive" (or whatever you named it) mapped to the specified path on the Mac.
Notice that it belongs to "501", which is the ID of my user account on the Mac. If I create a user and set the ID to 501, that user's name will be shown instead.
Also notice that the invisible system files are shown (in Finder I only see app, Parallels VM and william). Obviously you'll want to avoid messing with those. Perhaps better, share a subdirectory instead of the entire filesystem.
Troubleshooting
By default, the Linux boot process issues a mount command for each entry in /etc/fstab ("filesystem table"). If the new filesystem is not getting mounted, you can investigate what isn't working by executing the command yourself.
The mount command can be used on the Linux command line to mount a filesystem manually. You'll need to be connected as the root user, so either enter su - (then enter the root password), sudo su (then enter your own password), or else execute the commands as the currently connected user (e.g. oracle), placing sudo before each command, e.g. sudo mount -v /extdrive.
mount -v /extdrive (the -v is "verbose" mode) will attempt to mount the drive as you specified it in /etc/fstab. However, a common problem is that either the host Mac's firewall or its NFS server process rejects it, and all you see on the Linux command line is the mount command appearing to hang. To check what's going on, first go back to Firewall tab in the Mac's Sharing preferences, and hit the Advanced option, enable firewall logging if it isn't already enabled, and hit Open Log. This bring up a Console window showing the actual Firewall log in real time. Now go back to Linux and re-enter the mount command, and watch for "deny" entries appearing in the Firewall log. For example, when using NFS with Xubuntu I got log entries like this:
Sep 23 09:50:14 starbase-2 ipfw: 12190 Deny TCP 10.0.1.201:785 10.0.1.2:1011 in via en0 Sep 23 09:50:38 starbase-2 ipfw: 12190 Deny TCP 10.0.1.201:785 10.0.1.2:1011 in via en0 Sep 23 09:51:26 starbase-2 ipfw: 12190 Deny TCP 10.0.1.201:785 10.0.1.2:1011 in via en0
10.0.1.201 was the Xubuntu VM, and it was attempting to connect through port 1011 which I had not authorised. I added 1011 to the "TCP port numbers" list in the firewall settings to allow these connections.
If nothing is appearing in the Firewall log, then either it can't see the host at all (in my example 10.0.1.2 - you may need to double-check that you have entered the right IP address) or else the NFS server is not authorising the connection. Go back over the NFS Manager settings and make sure that the Linux VM's IP address is correctly specified. It should be entered in /etc/hosts, you should be able to ping it from the Mac's command line, and it should be listed in the "List of computers or computer groups" window in NFS Manager.