For many years, Network File System (NFS) has been the preferred method for sharing files among Linux and other UNIX-like computer systems. Although Mac OS X does support NFS connections from its Connect to Server window, you need to do a little trick on the Linux server for that server to accept connections from the Mac OS X computer.
The following procedure describes how to use the Connect to Server window from a Mac OS X client to access files and directories from a shared Linux NFS server. You can then use the files and directories (also called folders) that reside on the Linux NFS server as though they existed on your Mac OS X computer.
As I've mentioned, the procedure relies on being able to make a small change to how the Linux NFS server offers the shared directory. If you don't have access to the Linux server, you either need to ask the administrator of the Linux server to make the change or connect your Mac to the Linux NFS server manually. (I describe the manual procedure at the end of this section.)
To create an NFS shared directory in Linux and connect to it from a Mac client, do the following:
On the Linux server, export a shared directory using the NFS facility as described in Chapter 18. To be able to use the shared directory from Mac OS X, however, you must be sure to add the insecure option. For example, to share the /var/music directory from the Linux server named jukebox.linuxtoys.net, you can add the following line to the /etc/exports file on that server:
This example allows the /var/music directory to be shared with all computers (*) and allow read/write permission (rw). The insecure option lets clients that request the exported directory make the request from an insecure port (ports above 1024). This is important because the Mac OS X Connect to Server window makes its request to mount the shared directory from a port above 1024, and fails without the option.
On the Linux server, make sure the the NFS service is running and re-export the shared directory by typing the following (as root user):
# exportfs -a -v
On the Mac OS X client, select Go in the Finder bar at the top of the screen, and then select Connect to Server. The Connect to Server window appears.
On the Mac OS X client, type the address of the share directory into the Address box. For example, to connect to the shared NFS (nfs://) directory called /var/music from the computer named jukebox.linuxtoys.net, you can type the address: nfs://jukebox.linuxtoys.net/var/music, as shown in Figure 26-5.
Figure 26-5: Connect to an NFS server from the Connect to Server window.
If everything is working properly, an icon representing the server should appear on your Mac OS X desktop. Open that icon to see the contents of the shared directory. You can use the shared files and directories as though they were on your Mac (if permissions on the server permits you to do so). Drop the icon in the trash when you are done.
If you are unable to connect to the shared directory, go through the NFS procedures in Chapter 18 more carefully. In particular, make sure that firewall ports are open on the server and that user/host permissions are set to allow the level of access that you require.
You might very well not have any control over how the Linux NFS server is configured. So if the insecure option isn't set, you will fail to mount an NFS directory from the Mac's Connect to Server window. A possible workaround is to manually mount the NFS directory from Mac OS X and use a secure port. Here's how:
On the Mac OS X computer, gain access to the root user account as follows:
With the Folder icon selected, click Go ? Applications. The Applications folder appears.
Open the Utilities folder, then the Netinfo Manager utility.
Click on the lock icon on the Netinfo Manager window so that it unlocks.
Click Security ? Enable Root User. (If you see a Netinfo error, click OK.)
Type in and verify the new root user password, then click Verify. (Remember that password!)
Click the open lock icon to close it and prevent further changes.
On the Mac OS X computer, click the Terminal icon to open a shell and log in as root:
# su - Password: *******
Create a directory that is accessible to the user account of the person who wants to use the shared NFS directory on the Mac. For example, for the user chris you might type:
# mkdir /Users/chris/music # chown chris /Users/chris/music
Mount the NFS shared directory on the directory you just created. For example:
# mount -o "-P" jukebox.linuxtoys.net:/var/music /Users/chris/music
The -P says to use a priviledged port. Replace jukebox.linuxtoys.net and /var/music with the server's name and the shared directory, respectively. The user can now access /var/music from the /Users/chris/music directory on the Mac OS X.