Linux Project

NFS servers and clients
Thursday, 14 Feb 2002

Here is a short checklist of the actions we will take to set up an NFS server on pluto and a corresponding NFS client on cressida:

On the server pluto (IP address

On the client cressida (IP address Once again, on the server pluto (IP address Configuring the NFS server

Now let's get to work and follow our plan step-by-step. First, let's see if the Network File System, NFS, is already running on your machine. Type the command

rpcinfo -p

into a command window. If you see something like this, it is NOT running.

[root@pluto notes]# rpcinfo -p
   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  32768  status
    100024    1   tcp  32768  status

To start NFS, type the following command:

[root@pluto notes]# /etc/rc.d/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]

Now verify that services have started.

[root@pluto notes]# rpcinfo -p
   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  32768  status
    100024    1   tcp  32768  status
    100011    1   udp    961  rquotad
    100011    2   udp    961  rquotad
    100011    1   tcp    964  rquotad
    100011    2   tcp    964  rquotad
    100005    1   udp  32821  mountd
    100005    1   tcp  37065  mountd
    100005    2   udp  32821  mountd
    100005    2   tcp  37065  mountd
    100005    3   udp  32821  mountd
    100005    3   tcp  37065  mountd
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100021    1   udp  32822  nlockmgr
    100021    3   udp  32822  nlockmgr
    100021    4   udp  32822  nlockmgr

The next step is to configure the system so that the NFS server can recognize which hosts are authorized to use pluto's portmapper. Since client requests for NFS directories come into pluto's portmapper, that is the crucial access point. To allow cressida, with IP address, to access pluto's portmap process add the last line in the following display to pluto:/etc/hosts.allow:

# hosts.allow	This file describes the names of the hosts which are
#		allowed to use the local INET services, as decided
#		by the '/usr/sbin/tcpd' server.
in.ftpd: 152.97.,
in.telnetd: 152.97.,

The next step is to configure the system so that the NFS server can determine which hosts are authorized to request which directories. Authorized hosts, the directories they are allowed to request, and the restrictions on that sharing are listed in /etc/exports. Let's assume that we are working on pluto and we wish to export pluto:/etc/admin to the remote machine cressida, with IP address Edit pluto:/etc/exports so that it contains the following line:

[root@pluto parrish]# cat /etc/exports
/home/admin (ro,no_root_squash)

Now that /etc/exports has been updated, we must tell the server to re-export all the entries in that file. Issue the command

exportfs -r

Configuring the NFS client

Now move to the client cressida and create a mountpoint on which to mount the directory pluto:/home/admin.

mkdir /home/pluto/admin

Open emacs on cressida:/etc/fstab, and add the following line to the bottom of that file (assuming that the IP address of the server pluto is

pluto:/home/admin /home/pluto/admin nfs rsize=1024,wsize=1024 0 0

Finally, mount the remote directory pluto:/home/admin on the local mount point cressida:/home/pluto/admin with the command

mount -a

Verify that the mount succeeded by listing the contents of that directory.

Making the changes permanent

We are not quite done. If we reboot pluto we would have to restart the server all over again. In order to make the changes permanent, use the tool ksysv to automatically start NFS in runlevels 3 and 5.

ksysv &

Be VERY careful with this tool. This is equivalent to setting the parameters for your heart and brain functions! Find the entry for nfs in the leftmost panel, Available Services. CAREFULLY use your mouse to drag it over to the column for Runlevel 3 Start, and slip it in just after the entry for nfslock (number 14). You should see a brand new blue entry for nfs in that start column with newly assigned number 15. Now repeat that action, this time dragging the nfs icon from the Available Services column into the Runlevel 5 Start column, once again slotting it in just after number 14 nfslock. You should see a newly created blue entry under Runlevel 5 Start reading 15 nfs. SUPER CAREFULLY now, select File:Save Configuration and close the display. Restart your machine and pray. If you have been a good person, your nfs server will start automatically.

Congratulations! You are moving into the upper levels of Linux System and Network Management!