~  CHAPTER 18:    NETWORK FILE SYSTEM (NFS)  ~

                                   

 

 

Network File System (NFS) is the UNIX way of sharing files and applications across the

network.  The NFS concept is somewhat similar to that of Windows NT’s disk sharing in

that it allows you to attach to a disk and work with it as if it were a local drive – a very

handy tool for sharing files or a large disk with coworkers.

 

 

The Mechanics of NDS

 

  •   Making an NFS mount request for /export/home from the server nox, os that

the share appears locally as the /home directory.

 

  •   RPC Remote Procedure Calls are responsible for handling the request between

the client and the server.  RPC technology provides a standard mechanism for any

RPC client to contact the server and find out to which service the calls should be

directed.

 

  •   Portmapper.  Portmapper takes care of telling the client where the actual service

is located on the server.

 

 

NOTE:  If a NFS server is rebooted, all clients will automatically continue their operations

with the server as soon as the server is back online.

 

 

 

Versions of NFS

 

NFS is not a static protocol.  Standards committees has helped NFS evolve to take advantage

of new technologies as well as changes in usage patterns.

Today, the standards are up to version 3.0, with 4.0 in the works.

 

 

Enabling NFS

 

If you aren’t sure about your system, use the ksysv tools.  It will show NFS as started in

runlevel 3 and 5.

 

======================================================================

 

linux18.html                                                    PAGE 2                                                       2002/07/20

 

 

 

 

The Components of NFS

 

 

NFS under Linux is made up of five parts:  (built into the Kernel):

 

 

  •   rpc.statd.  This daemon handles the file-locking issues between the client and

the server.

  •   rpc.quotad.  As it name suggests, rpc.quotad supplies the interface between NFS and the

quota manager.

  •   rpc.mountd.  Takes care of verifying that the client has enough permissions to make

the request.

  •   rpc.nfsd.  Main component of NFS system. 
  •   rpc.lockd.  Use this daemon to handle lock recovery on crashed systems.

 

 

 

 

Configuring NFS Servers

 

The second step is to start the NFS server processes that read the /etc/exports file and

follow the specifications.

 

 

The /etc/exports Configuration File

 

NFS servers have only one configuration file:  /etc/exports.  This file lists the partitions that

are sharable, the hosts they can be shared with, and with what permissions.  See page 418-420

 

 

Configuring NFS Clients

 

NFS clients are remarkably easy to configure under Linux, because they don’t require

any new or additional software to be loaded.

 

The only requirement is that the kernel be compiled to support NFS.  All of the distributions

come with this feature enabled by default.  Aside form the kernel, the only other change is

to the options in the mount command.

 

 

The mount Command.

 

The mount options can also be used in the /etc/fstab file.  This same entry in the /etc/fstab

file would look like this:  See page 421

 

 

Soft vs. Hard Mounts

 

By default, NFS operations are hard, which means they continue their attempts to contact

the server indefinitely.  This arrangement is not always beneficial, however.  It causes a

problem if an emergency shutdown of all systems is performed.

 

 

======================================================================

 

linux18.html                                                    PAGE 3                                                       2002/07/19

 

 

 

 

Enabling a soft mount allows the client to time out the connection after a number of retries

(specified with the retrans=r option).

 

 

Cross-Mounting Disks

 

Cross-mounting is the process of having server A NFS mounting server B’s disks, and server

B NFS mounting server A’s disks.  In general, unless you have reason not to use the intr option,

it is usually a good idea to do so.

 

 

Performance Tuning

 

 

The default block size that gets transmitted with NFS is 1K.  This is handy, since it fits nicely into

one packet and, should any packets get dropped, NFS has to retransmit very few packets.  The

downside to this is that it doesn’t take advantage of the fact that most networking stacks are fast

enough to keep up with segmenting larger blocks of data for transport, and that most networks

are reliable enough that it is extremely rare to lose a block of data.

 

 

Common Uses for NFS Partitions

 

  • To hold popular programs.
  • To hold home directories.
  • For shared mail spools.

 

 

Hard vs. Soft Mounts

 

  •   On an NFS file system that is hard mounted, the client must commit all changes to the server

before allowing other operations.  The client will continue trying to contact the server, until

the server sends back an acknowledgement.

  •   Soft mounts, on the other hand, aren’t quite persistent about getting data written to the NFS

server’s disk.  The client will try to access the server and commit unwritten data, but after a

specified timeout period (number of retries), the client will give up and return control to the

user.  Although this has the potential of causing data loss, it allows clients to handle failed

NFS servers more gracefully.

 

 

 

======================================================================

 

linux18.html                                                    PAGE 4                                                       2002/07/19

 

 

 

 

Summary:

 

  •   NFS is a stateless protocol.  Clients can’t tell the difference between a crashed server and a slow

server; thus recovery is automatic when the server comes back up.

  •   The key server processes in NFS are rpc.statd, rpc.quotad, rpc.mountd, and rpc.nfsd.
  •   Use rpcinfo^-p to view all the RPC services on your system.
  •   Use exportfs^-a to export all the file systems specified in the /etc/exports file.
  •   NFS is a powerful tool for sharing disks.  Be sure to spend some time experimenting with it to

meet your system’s resource-sharing needs.