next up previous contents
Next: Setting Up NFS Client Up: Network File System Previous: Step by Step Instructions   Contents

Setting up an NFS server

You should make sure that the networking is sane. That is you should be able to telnet among the machines you want to register for the NFS service. If this does not function properly, please consult the document on how to setup network on your system and/or your network administrator.

  1. Start the portmapper

    It's either called portmap or rpc.portmap and it should live in the /usr/sbin directory (on some machines it's called rpcbind). It should be started every time you boot your machine, so you need to make/edit the relevant rc scripts which is outside the scope of this document. It's likely that the system you are currently using will have a script (portmap) for starting the portmap service under /etc/rc.d/init.d directory. You can start portmap7.1 by hand now:

     
    # /etc/rc.d/init.d/portmap start
    
    Check that it lives by running ps aux and rpcinfo -p.

  2. Start NFS server

    The core of NFS server are two programs called mountd (rpc.mountd) and nfsd (rpc.nfsd). Before running these two programs we should tell the system how to share files by editing the file /etc/exports. As a general example, if you want to share the file system /usr/local which resides on the machine cluster3 with the machine called cluster1 and cluster2, you should then put the following in the exports file located in cluster3 machine.

     
    /usr/local      cluster1(rw)
    /usr/local      cluster2(rw)
    
    The above configuration tells NFS to allow cluster1 and cluster2 to read and write from/to the /usr/local file system (notice the (rw) option in each line). There are other options such as read only (ro) which can be specified to vary the sharing behavior. For more information please consult man pages, e.g., try man exports. After this step, you are ready for starting both mountd and nfsd daemon programs. Running the two utilities should be very easy on the system installed Redhat Linux distribution. Only one startup script, called nfs, which is located under /etc/rc.d/init.d directory is responsible for starting the two program daemons above. To start this script, simply execute the following commands as root:

     
    # /etc/rc.d/init.d/nfs stop
    # /etc/rc.d/init.d/nfs start
    
    The first command stops the NFS service while the second command reactivates it. The alternative to issuing two commands is by using the option restart. However, experience shows us that the option restart can be very unstable, i.e., the daemons aren't brought up properly. Enforcing the two commands above somehow yields better result. As with other system services, the nfs script should be set ready when the machine boot with the setup utility as described above.

  3. Maintaining Export Files

    Once you have everything running, you might sometimes need to change the /etc/exports which specifies the directories to share among machines. The utility called exportfs is used to create the export table from /etc/exports. The export table is stored in /var/lib/nfs/xtab which is read by mountd when a remote system requests access to mount a file tree. So, after you change the /etc/exports file, run the command:

     
    # exportfs -r
    
    In Redhat, this utility is already included in /etc/rc.d/init.d/nfs, so in general you can run it by:
     
    # /etc/rc.d/init.d/nfs reload
    


next up previous contents
Next: Setting Up NFS Client Up: Network File System Previous: Step by Step Instructions   Contents
root 2002-09-30