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
The NFS protocol uses ports 2049 and 111,2 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.
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.