Thursday, May 15, 2008

Mounting a Linux NFS point on a Mac client

Mac OS X 10.5.2, Linux (Debian) kernel 2.6.21.5

Quick tip for anyone trying to connect to a Linux server's NFS share from a Mac. The Finder provides a way to do this (from the menu bar, Go->Connect to server, then nfs://<server_name>/<mount_point>). Turns out this may not work if your distribution of Linux requires NFS connections to come from a trusted port. The solution requires you to open a terminal and type:

sudo /sbin/mount_nfs -o resvport <server_name>:<mount_point>

In this example, the Mac has an IP address of 192.168.1.1 and the Linux server's is 192.168.1.34.
So on my linux box, my /etc/exports file looks like:



# /etc/exports: the access control list for filesystems which may be exported

# to NFS clients. See exports(5).

/home/music 192.168.1.0/255.255.255.0(ro,sync)




On the Mac, I type:

mkdir /tmp/mnt (make a directory where I want to mount the remote directory

sudo /sbin/mount_nfs -o resvport 192.168.1.34:/home/music /tmp/mnt



You should now be able to cd /tmp/mnt and see the contents of the remote directory.



Troubleshooting Notes:
If you are having trouble, look in the logs on the Linux/Mac boxes. On Linux, they are usually in /var/log. For the Mac, use the Console application in the Utilities folder. After you add an entry to /etc/exports on the Linux box, you may have to tell mountd(8) and nfsd(8) to re-read the file. Some systems allow you to do this with the command exportfs -a. If that command does not work, then send HUP signals to the two server processes:

sudo killall -HUP rpc.mountd

sudo killall -HUP rpc.nfsd