Sharing files between Ubuntu and OSX (Snow Leopard) using NFS

NFS (Network File System) is an old way of sharing files between UNIX systems. It was written way before the time when we started sharing files the way we are sharing them right now with Windows servers and workstations.

I actually would have not installed it, because I already have a Samba server in the LAN. However, Snow Leopard (even Leopard, probably moreso) has an unpredictable behavior when detecting Samba shares. So I decided to install an NFS share on the same Samba server–just for my mac mini and macbook; of course, if you have linux workstations and notebooks, it wouldn’t hurt to prepare them for NFS use.

To make this solution work, you need to do something on the server side. My server has the following details.

root@whitepc:~# lsb_release -a
Distributor ID:	Ubuntu
Description:	Ubuntu 9.04
Release:	9.04
Codename:	jaunty

And this is the OSX info

mac mini conf.png

OSX comes with the necessary software to mount an NFS volume, so I didn’t have to do anything on that side.

Preparing the Ubuntu server for NFS

You need to get some packages. Get a terminal (xterm or gnome-terminal or aterm, whatever is your choice)

# apt get install nfs-kernel-server nfs-common portmap sysv-rc-conf

The sysv-rc-conf is just a handy utility so that I can start | stop | restart any service in my Ubuntu box, it’s a ncurses user interface which let you manage the state of services by just pointing to the service using the arrow keys, then pressing the plus sign (+) to start a service and the minus (-) sign to stop a service

After getting the packages, you will need to edit /etc/exports and add some lines so that you can expose the folders that you would like share using NFS

replace /home and /mnt/badass with your own folders that you’d like to share. I had to include the ‘insecure’ option in the exports declaration because OSX wouldn’t let me mount without that option. There are other types of declaration you can do in the exports file, but it’s beyond the scope of this post–I’ll put some more time on this one, then I’ll redo this post to include the other options for NFS exports file.

After you have done editing /etc/exports, you should restart the nfs server, you can do that 2 ways. First is by

$ sudo /etc/init.d/nfs-kernel-server restart

The second is to invoke sysv-rc-conf from the command line, then use your arrow keys to find nfs-kernel-server, then press ‘-’ sign to stop, then press ‘+’ sign to start.

Mounting shares from OSX

Just like any other mounts, you should create a mount point (a folder) in your OSX drive.

$ mkdir ~/mymount
$ cd ~
$ sudo mount servername:/mnt/badass ~/mymount

All the contents of the shared files in your NFS server should now be accessible within the mymount folder, just cd to ~/mymount and use it as it the file system is local to your OSX.

If you want to show appreciation for my efforts dear reader, you could buy me a tall hazel nut Americano ($2) via PayPal. Thanks
Navigation
(previous post)
(next post)
| | | | .

{4 Comments below .. you can add one }


Tom Franco 12.5.2009at 19:57

Hello !
First I am a command line novice. I repeat NOVICE

I was able to edit the /etc/exports file but when I restarted NFS the response was…..

exportfs: No host name given with /home/tom/Desktop/macpro (rw,sync,no_subtree_check,insecure), suggest *(rw,sync,no_subtree_check,insecure) to avoid warning

Don’t I need to specify a host name?

OR

Did I type the command on the exports file with the incorrect syntax?

() ().


Ted Heich 12.6.2009at 05:46

Tom,
What’s your server info (distro, version), let me try to see if I have one of those here, then I’ll try to recreate the problem.

The instructions in this post is actually running on my Ubuntu 9.04 (server), I removed the hostname option–which means everybody in the LAN will have access to it. You specify a hostname if you want a specific computer or range of computers to be able to access the share–for example;

/folderToShare 192.168.1.1/24(rw,no_root_squash,async)

this statement in the exports file allows computers with IP address ranging from 192.168.1.1 up until 192.168.1.255 to access the share.

Also, a bit of clarification, is your NFS server a Linux box and the NFS client is a mac? or is the other way around?


Peter Stankiewicz 1.11.2010at 05:16

It worked fine for except for one thing: the finder won’t let me drop any files into the mounted folder. The contents are perfectly visible but I can’t drop files from my mac into the folder. Is there some option that one should add to be able to drop files into the folder?


Ted Heich 1.11.2010at 05:57

@peter, can you check the permissions of the folder on you are sharing on the NFS server. This can be done by typing the command ls -l on terminal on the server, on the output, can you check if the folder you are sharing has got right write permissions for owner or group or others.

Leave a comment