Wednesday, August 12, 2009

The exportfs Command in NFS Server.

The Main Advantage of exportfs commands the /usr/sbin/exportfs command allows the root user to selectively export or unexport directories without restarting the NFS service.
The following is a list of commonly used options available for exportfs command-
-r — Causes all directories listed in /etc/exports to be exported by constructing a new export list in /etc/lib/nfs/xtab. This option effectively refreshes the export list with any changes that have been made to /etc/exports.
-a — Causes all directories to be exported or unexported, depending on what other options are passed to /usr/sbin/exportfs. If no other options are specified, /usr/sbin/exportfs exports all file systems specified in /etc/exports.
-i — Ignores /etc/exports; only options given from the command line are used to define exported file systems.
-u — Unexports all shared directories. The command /usr/sbin/exportfs -ua suspends NFS file sharing while keeping all NFS daemons up. To reenable NFS sharing, type exportfs -r.

-v — Verbose operation, where the file systems being exported or unexported are displayed in greater detail when the exportfs command is executed.
eg.
exportfs -rav

Note:-When the nfs service starts or stop, the /usr/sbin/exportfs command launches and reads this file, and passes to rpc.mountd and rpc.nfsd the file systems available to remote users.

Soft vs. Hard Mounting in NFS Server.

Soft Mounting-
If a file request fails, the NFS client will report an error to the process on the client machine requesting the file access. Some programs can handle this with composure, most won't. We do not recommend using this setting; it is a recipe for corrupted files and lost data. You should especially not use this for Mail Server.
If you want to use soft mounting.use timeo option with it.,the timeo option to set a timeout interval, in tenths of a second.
e.g.
mount -o soft,timeo=300 rahul:/home /mnt/rahulhome

Hard Mounting-


The program accessing a file on a NFS mounted file system will hang when the server crashes. The process cannot be interrupted or killed (except by a "sure kill") unless you also specify intr. When the NFS server is back online the program will continue undisturbed from where it was. We recommend using hard,intr on all NFS mounted file systems.

Picking up the from previous example, the fstab entry would now look like:
# device mountpoint fs-type options dump fsckord

rahul.pooja.com:/home /mnt/rahulhome nfs rw,hard,intr 0 0