NFS Shares between Ubuntu 12.04 and Mac OSX 10.8
Mounting NFS volumes between Ubuntu and Mac OS X 10.8 was a problem for weeks, I started using SMB shares as I couldn’t get both systems live in harmony! But today fiddling with zillion different configurations in both sides I got Mac OS X to accept my NFS exports from Ubuntu 12.04. This is how I got it working….
First you need to export directories from Ubuntu end, so you may need nfs-kernel-server package installed in the ubuntu system.
sudo apt-get install nfs-kernel-server
Then edit /etc/exports file as root. Normally, you would
sudo nano /etc/exports
Then add whatever directory you wanna share to the Mac OS X (or any NFS compatible computer). Here, I have shared my Projects directory under /home/purinda (my Home directory).
/home/purinda/Projects *(rw,async,insecure,all_squash,no_subtree_check,anonuid=1001,anongid=1001)
To exit nano after saving your changes, use Control+O to save the file and Control+X to exit.
Lets go through each settings to understand what it does,
“/home/purinda/Projects” is what you are sharing with others.
* represents that you’re sharing it with any client machine, usually for security reasons you may want to put something line “192.168.1.10/32” without quotes to share it only with a single client, or “192.168.1.0/24” to share it to all clients in your Class C network. I am * (any) as the machine I am working on is a virtual machine and only exposed to the host computer and other VMs in the virtual network.
manual page for ‘exports’ (man exports) gives a good explanation.
Once you have edited the exports file correctly. You can restart nfsd (nfs server daemon) using
sudo service nfs-kernel-server reload
You can also use following command to export new shared directories, whenever you make changes to your exports file,
sudo exportfs -ra
To mount it, on the Mac get a terminal and type (change host and directory path to suit your requirement)
mount -t nfs -o nfsvers=2 192.168.56.2:/home/purinda/Projects /Volumes/Projects/
‘nfsvers=2’ option is important for mac osx and ubuntu to be compatible with each other.
UPDATE: 19/09/2014
I tried to follow my own instructions and failed, not because they were wrong but the way Ubuntu upstart initiates services.
When I tried to mount the exported directory on the client Mac I got “Cannot retrieve info from host: xxx.xxx.xxx.xxx: RPC: Program not registered“.
The way to fix the issue is, on the NFS server restart rpcbind service before starting NFS-kernel-server.
So
sudo service rpcbind restart
then
sudo service nfs-kernel-server restart
Try remounting