Network File Systems (NFS)


Overview:

Network File Systems is a means by which you can mount remote filesystems over a network such that they appear as a local filesystem. This allows LAN's as well as WAN's to achieve a higher level of unity between machines (i.e. Each machine acts like every other machine for certian file systems)

Daemons:

rpc.mountd, rpc.nfsd: mountd and nfsd are responsible for validating requests from clients and assuring that they are allowed to mount exported file systems. Once they have validated the client they are then responsible for serving the clients requests for NFS information.

Setup :

In order for NFS to be successfully configured you need to have both machines networked with the nfsd and mountd daemons running in the background. Also your kernel has to have NFS support compiled into it. If you are not sure if your kernel has NFS support you can read the /proc/filesystems file and see whether or not your kernel supports it. If it does support NFS the command :

cat /proc/filesystems

should produce output similar to:

                minix
                ext2
                msdos
        nodev   proc
        nodev   nfs
      
If the nfs line is not located in the file then your kernel does not support nfs and you need to recompile it.

By default mountd does not want to allow any remote client to mount its local filesystems. This is due to security. Therefore there must be a mechanism by which we can tell it which what filesystems to export and to whom. In comes the /etc/exports file which allows us to do this.

        /home              Mako(rw)   Marlin(rw)
        /usr/local/bin     Mako(ro)   Marlin(rw)
        /scratch           (rw)
      
As can be seen above, for each directory to export you can specify a host(s) to mount and what permissions to give that host. In the example above Mako and Marlin are both able to mount /home with read/write permissions, however, only Marlin has read/write permissions for the /usr/local/bin directory. /scratch is mountable read/write by any machine on the LAN, not just Mako and Marlin (the lack of host names show this.)

Note: wildcards are allowed in the host names listed in the /etc/exports file. For example:

/home Ma*.myLan.com

allows Marlin.myLan.com and Mako.myLan.com to mount /home but not the host Frogger.myLan.com and not Minki.myLan.com.

Options :

When the mountd/nfsd daemons start up, they read the /etc/exports file and store it in memory. This means that whenever you edit the file the changes do not take effect. In order to get the daemons to re-read the files and reconfigure themselves you either need to kill them and restart them, or send them the HUP signal. Most daemons have a default behavior of catching the HUP signal and using it as a message to reconfigure themselves. This signal can be sent with the following commands:

kill -HUP pid or kill -1 pid.

Mounting NFS :

Mounting Network File Systems is done much like mounting local filesystems with one major difference. This difference is that instead of using a device name you will specify the remote volume prepended by the serving host and a colon. For example to mount /usr/local/bin from the host Mako the command is:

mount Mako:/usr/local/bin /usr/local/bin

The mount command is smart enough to see the Mako: in the command and realize that the type of filesystem is NFS, therefore you do not need to specify the type of filesystem.

Options :

Automount:

Automount is method of automatically mounting a network file system upon recieving NFS requests to access the system. Using this method of mounting, the NFS filesystems are not located in the /etc/fstab file. The advantage of this is that if you have many volumes mounted via NFS they do not have to all be mounted at the same time taking up system resources. They are only mounted when needed. The other advantage to this is that it allows the mounting of the same file system from different hosts. This allows the access to a filesystem even if one of the hosts it is on is unreachable (ie redundancy.)

Questions???


John Spicer