Writing Archive

NFS in Mac OS 10.5 Leopard

Okay Okay, so I haven’t posted in while. Well, now Its decided. In this world, one which lacks Leopard howtos, I’ll do my best to write some posts that will in the end save you the time you would spend searching google. :)

NFS and OS X

Anyway, some of us have had Leopard for a couple of weeks, and i recommend it for anyone who has a fairly new mac, by which i mean that the only consideration should be if you have enough performance to get everything out of leopard. Leopard has a lot of new “features”, one of which I’ll be explaing today.

NFS isn’t something new, and its not even something new for Mac OS. The client to mount NFS is included on almost every *nix, and doesn’t require any additional installation (usually). It also has better performance than Samba (thats what windows uses to share files), and has a fairly extensive list of configuration options. Of course, nfs isn’t perfect for everything, but if your computers run *nix (aka BSD/Unix/Mac/Linux), then NFS might be the easiest file sharing protocol to configure. After all, its basically already there, so you save yourself the install.

I’m going to assume you have NFS configured on the server, this is the computer hosting the files. If not, well its actually pretty simple, and NFS has probably the best howtos out there. You can find it here. Anyway back to the client side, running OS X. So in 10.4, mounting NFS was kind of, well a pain. Mac OS connects to an “insecure” port by default. In other words it doesn’t send a request to the server for a port. This means if you run a firewall, you can’t connect via finder, because Mac OS will attempt to connect to a port that will be blocked, since its not in the firewall rules. Not only that, you have to configure your your shares to be “insecure” otherwise /var/log/messages will get something along the lines of:

russo@marx:~$ cat /var/log/messages | grep nfsd
Nov 8 16:56:15 marx kernel: nfsd: request from insecure port (192.168.0.4:49204)!

Directory Utility

There was a solution in 10.4, and it was fairly complicated and involved setting everything up with NetInfo Manager. This procedure was quite tedious, as you can see in this howto. But we’re not in 10.4 anymore (thank god!) And guess what… NetInfo is gone! And replaced by something, much more user friendly. The new replacement is called, Directory Utility. And can be found in your Utilities folder, imagine that! Fire it up, lets take a look!

So at first site, there probably won’t be much there, especially on a home network. But, this doesn’t matter we’re not configuring Directory Services, we’re here for the NFS mounts. Just click “Show Advanced Settings” and you’ll see “Mounts” appear up top. Click that. Next you should see something like this

Click the lock in the bottom left corner, to allow you to add/edit mounts. Enter the username and password of an Administrator on the computer (Chuck Norris administers mine). Now you should be able to click the + to add a mount. By the way, with Directory Utility you don’t have to reboot to see changes. You just click that apply in the corner. How sweet is that?

The syntax here is a bit different than mount in CLI, however the syntax still contains that which made many new users make a mistake. :) The syntax is

nfs://<hostname or ip>/<full path to directory>

Remember, /full/path/to/dir is the full path on the server!

Also enter, the directory where you want this share to be mounted. Its probably best to keep everything under either /Volumes or /Network. This way all users can easily access to the shares. You can always add aliases to your home directory, or wherever you want these mounts to actually appear. Now if you, just want to automount “insecure” mounts, than you’re basically done at this point. However we want to add “secure” mounts. This means we need to specify the “Privelaged” flag to the mount. This will cause it to use a port designated by the server. Click the little triangle next to “Advanced Mount Parameters” And you’ll see something like this:

all we have to do is add, “-P”. This makes the mount use a privelaged port. Now click “Verify”. At this point, its good to mention that if Directory Utility only checks if the server that you entered is running nfs and not if the mount is actually functional. Now click “Apply”

Nothing Happend…

Well it did, but you might not be able to see it. At the very least the mount point has been created, and you can check this by opening finder and going to either /Volumes or /Network (EDIT: or wherever you mounted you shaere). To get there you’ll have to type command (apple) + shift + G, and then type in where you want to go. Okay, so now you should see it there, BUT you probably won’t be able to write to even if you didn’t mount it read-only. Why is that, you ask? Well you don’t have permissions, silly! And even if you your user does have permissions to write, even if your user exists on both machines, he probably won’t have the same gid/uid. How can you check? Just use the id command:

lenin:~ russo$ id
uid=501(russo) gid=20(staff)

Just as a side note Mac OS begins with 500, whereas most linux distros begin with 1000. So now you can either change the gid/uid of one of the machines so that they do match, or run “chmod 777″ the directory on the server… that should be it. You should be able to write now!

EDIT: There are also ways to map IPs, hostnames and authenticated users to users on the machine. Maping ips and hostnames is fairly easy, you simply add anonuid=youruid, anongid=yourgid to the options in the /etc/exports file. (Thanks Paolo)

How do i get the share in my Finder Sidebar?

Simple! Just click the folder and drag it while holding apple + option. You can place it under “Places” in this manner. Even if you’re not an admin user.

EDIT: This wasn’t clear enough for some. You cannot create aliases for the actual mounts, however you can create a folder enclosing the mounts and create an alias for that. I.e /Volumes/Hostname and put all the mounts in /Volumes/Hostname. I hope its a little bit easier to understand now…

And if you appreciate all my hard work, please feel free to donate:

Read more...