Appendix 9

 Appendix 9
2.2.7 NFS

     Here we are going to describe the setting process of NFS(Network File System) server as well as NFS client. As we have already mentioned earlier that NFS is a client-server application we have to set both the client and server for taking the benefit of NFS. At first we began with the setting of Server:
     Let's assume that we are setting mapletown(192.168.0.16) as a NFS server and maple as a NFS client.

NFS Server Setting

There's only three things you have to do set up a NFS server:

  • Edit the /etc/exports file
  • Run a mount daemon(that's mountd)
  • Run a nfs daemon(thts nfsd)

(But more clearly telling you should require rpc.lockd, rpc.stad)
Here's the sample /etc/exports file from mapletown(192.168.0.16):

---------------- Start of /etc/exports file -------------------
mapletown@junan:/home/junan{754}% cat /etc/exports
/usr -network=192.168.0
/cdrom -ro -network=192.168.0
---------------- Start of /etc/exports file -------------------

You can refer to exports(5) for more reference on writing this file. But to give you an easy starting let us explain these lines. The first column(/usr or /cdrom) directs which directory to export to other clients, -network option directs tells to who should be eligible clients(specific names like 192.168.0.3 should have worked just fine, but for some unknown reason it didn't), -ro options directs that these files should be exported as read only. The next step you need to do is run the mount daemon:

mapletown# mountd -r
mapletown# showmount -e
Exports list on localhost:
/usr 192.168.0.0
/cdrom 192.168.0.0

Now you can see that your mountd is running. If you try from your clients(assuming that your clients are set as nfs clients) you gill get a message like:

RPC program not registered

Next comes the part of running nfsd. You should run nfsd with following options:

mapletown# nfsd -u -t 4

It tells nfsd to run four daemons. If you specify less number of daemons it might slowdown the remote mounting or there might be no mounting at all. At least four daemons are required(you are welcome to test what happens when there is less than four daemons).
But if you have any problem you can always go back to the /etc/rc.network part and give a quick view:

-------------------------- Start of a quick view of /etc/rc.network ---------------------
if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then
     echo -n ' mountd'
     if [ "X${weak_mountd_authentication}" = X"YES" ]; then
          mountd_flags="-n"
     fi
     mountd ${mountd_flags}
     if [ "X${nfs_reserved_port_only}" = X"YES" ]; then
          echo -n ' nfsprivport=YES'
          sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1
     fi
     echo -n ' nfsd'; nfsd ${nfs_server_flags}
     if [ "X$rpc_lockd_enable" = X"YES" ]; then
          echo -n ' rpc.lockd'; rpc.lockd
     fi
     if [ "X$rpc_statd_enable" = X"YES" ]; then
          echo -n ' rpc.statd'; rpc.statd
     fi
fi
-------------------------- End of a quick view of /etc/rc.network ---------------------

Most of the variables are defined in rc.conf, so before running these options please make sure that you read the variables from rc.conf. Though we didn
t give any idea of how to start all those rpc.lockd or rpc.statd you can clearly find from the excerpt that you can run rcp.lock as only rpc.lock. Same with the rpc.statd.
So, this is all you should need to set up a NFS server.

NFS Client Setting:

All you have to do is:

maple# nfsiod
This should set you as nfs client. Now let's try:

maple# mkdir /tmp/mapletown
maple# mount mapletown:/usr /tmp/mapletown

That's all. Now you should be accessing mapletown's /usr directory(not necessarily all the files under that name) as local files in /tmp/mapletown, but unfortunately as read only files only.
     Now that we did it manually, you might like to do it while you hosts get up. It
s also very easy to do, just set the following flags in /etc/rc.conf file on the server and on the client respectively.

---------------------- Start of /etc/rc.conf file on ther NFS server ------------------
nfs_server_enable="YES"
nfs_server_flags="-u -t 4"
mountd_flags="-r"
nfs_reserved_port_only="NO"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
portmap_enable="YES"
portmap_flags=""
---------------------- End of /etc/rc.conf file on ther NFS server ------------------

---------------------- Start of /etc/rc.conf file on ther NFS client ------------------
nfs_client_enable="YES"
nfs_client_flags="-n 4"
mountd_flags="-r"
nfs_reserved_port_only="NO"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
portmap_enable="YES"
portmap_flags=""
---------------------- End of /etc/rc.conf file on ther NFS server ------------------

In case you might want to mount on the mount points on the client automatically, when the client gets up you can set the /etc/fstab file as below:

---------------------- Start of /etc/fstab file on ther NFS server ------------------
# Device Mountpoint FStype Options Dump Pass#
-------------- Omitted Here ----------
mapletown:/usr /tmp/mapletown/ nfs rw,auto 0 0
mapletown:/cdrom /cdrom cd9660 ro,auto 0 0
---------------------- End of /etc/fstab file on ther NFS server ------------------

But necessary system files should not be imported(export can be accepted, though) in this way of auto-mounting. There is always some possibility of remote server(NFS server) not being available which will might force you to boot in a single user mode.
instead of domain name, like: telnet 202.251.39.129 or else.

| Home | Introduction | An Overview of Our Network | System Administration | Security | Conclusion | Acknowledgements | References | Appendix 1 | Appendix 2 | Appendix 3 | Appendix 4 | Appendix 5 | Appendix 6 | Appendix 7 | Appendix 8 | Appendix 9 | Appendix 10

This page is maintained by:
jchakma@yahoo.com