To set up an NFS server

To set up the NFS server you need to set up the configuration files and start NFS.

Setting up the configuration files

There are three main configuration files you will need to edit to set up an NFS server:
  • /etc/exports
  • /etc/hosts.allow
  • /etc/hosts.deny

For NFS to work, you only need to edit /etc/exports. However, this might result in an insecure setup and it is strongly recommended that the relevant changes are made to /etc/hosts.allow and /etc/hosts.deny to prevent security problems.

The /etc/exports file contains a list of entries indicating a shared volume and how it is shared. For a detailed description of setup options for the file type man export at the command prompt. To add a new entry to the file:
  1. Open the file with a file editor.
  2. Add the following line:
    directory client(option[,option...])
  • directory is the directory that you want to share. If you share a directory, then all directories under it within the same file system will be shared as well.
  • client is the client machine that will have access to the directory. It can be listed by DNS or IP address.
  • option is a listing for the client machine that describes the access that machine will have to the directory. For a full list of options type man exports at the command prompt. Some of the more common options include:
    ro The default value. The directory is shared read only and the client machine will not be able to write it.
    rw The client machine will have read and write access to the directory.
    no_root_squash By default, any file request made by user root on the client machine is treated as if it is made by user nobody on the server. If this option is selected is selected, then root on the client machine will have the same level of access to the files on the system as root on the server.
    Note: Please note the potential security implications with this option.
For example:

Starting the server

The portmap and associated rpc daemons need to be running before you can start NFS. Refer to the topicTo verify that NFS is running.

To start NFS, from a command prompt type:
/etc/init.d/nfs start

Changes to /etc/exports

If you make changes to /etc/exports and the NFS server is already running, you will need to force nfsd to read /etc/exports to apply the changes. From a command prompt type:
usr/sbin/exportfs -ra