NFS Configuration

NFS stands for Network File System; it is a way to share files between machines as if they were on your local hard drive. Linux can be both an NFS server and an NFS client, which means that it can export filesystems to other systems, and mount filesystems exported from other machines.

Mounting NFS Filesystems

Use the mount command to mount an NFS filesystem from another machine:

mkdir /mnt/local # Only required if /mnt/local doesn't exist
mount bigdog:/mnt/export /mnt/local

In this command, bigdog is the hostname of the NFS fileserver, /mnt/export is the filesystem that bigdog is exporting, and /mnt/local is a directory on the local machine where we want to mount the filesystem. After the mount command runs (and if we have the proper permissions from bigdog) we can enter ls /mnt/local and get a listing of the files in /mnt/export on bigdog.

Exporting NFS Filesystems

The file that controls what filesystems you wish to export is /etc/exports. Its format is:
directory       hostname(options)
the (options) are discretional. For example:
would allow to mount /mnt/export, but:
would just allow speedy to mount /mnt/export read-only.

Each time you change /etc/exports, you must tell the NFS daemons to examine it for new information. One simple way to accomplish this is to just stop and start the daemons:

/etc/rc.d/init.d/nfs stop
/etc/rc.d/init.d/nfs start

Or you can restart the daemons with this command:

/etc/rc.d/init.d/nfs restart

The following will also work:

killall -HUP rpc.nfsd rpc.mountd

See the following man pages for more details: nfsd(8), mountd(8), and exports(5). Another good reference is Managing NFS and NIS Services, by Hal Stern, published by O'Reilly & Associates.