If you install CentOS, Xubuntu or another free Linux1 on your Mac in a Parallels VM (for example as a platform for Oracle), you will notice early on that there is no way to share files between the host Mac and the VM. This functionality is provided for those rich fat-cat Windows VMs, but not for the likes of us. However, help is at hand in the form of NFS (Network File System), which is included as standard in both Mac OSX and Linux.
The way this will work is that NFS server daemons (background processes) will run on the Mac, listening for requests from the client (Linux in this case). You can configure the number of processes you want to have running. The server process will handle read and write requests from the client (much like FTP, HTTP and so on). When you set up an NFS share, you specify what directory you want to make available and with what permissions. 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.
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.
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.
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 nfsThere 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.