Section 17.3:NFS Client Configuration Files
17.3 NFS Client Configuration Files
Any NFS share made available by a server can be mounted using various methods. Of course, the
share can be manually mounted, using themount command, to acquire the exported filesystem at a
particular mount point. However, this requires that the root user type the mount command every time
the system restarts. In addition, the root user must remember to unmount the filesystem when shutting
down the machine. Two methods of configuring NFS mounts include modifying the /etc/fstab
or utilizing the autofs service.
17.3.1 /etc/fstab
Placing a properly formatted line in the /etc/fstab file has the same effect as manually mounting
the exported filesystem. The /etc/fstab file is read by the /etc/rc.d/init.d/netfs script
at system startup. The proper filesystem mounts, including NFS, are put into place.
A sample /etc/fstab line to mount an NFS export looks like the following:
<server-host> : </path/to/shared/directory> </local/mount/point>
nfs <options> 0 0
The <server-host> relates to the hostname, IP address, or fully qualified domain name of the
server exporting the filesystem. The </path/to/shared/directory> tells the server what
export to mount. The </local/mount/point> specifies where on the local filesystem to mount
the exported directory. This mount point must exist before /etc/fstab is read or the mount will
fail. The nfs option specifies the type of filesystem being mounted.
The <options> area specifies how the filesystem is to be mounted. For example, if the options area
states rw,suid on a particular mount, the exported filesystem will be mounted read-write and the
user and group ID set by the server will be used. Note, parentheses are not to be used here. For more
mount options, see Section 17.3.3, Common NFS Mount Options.
17.3.2 autofs
One drawback to using /etc/fstab is that, regardless of how much you use that mounted filesys-
tem, your system must dedicate resources to keep that mount in place. This is not a problem with one
or two mounts, but when your system is maintaining mounts to a dozen systems at one time, overall
system performance can suffer. An alternative to /etc/fstab is to use the kernel-based auto-
mount utility, which will mount and unmount NFS filesystems automatically, saving resources.
The autofs script, located in /etc/rc.d/init.d, is used to control automount through the
/etc/auto.master primary configuration file. While automount can be specified on the com-
mand line, it is more convenient to specify the mount points, hostname, exported directory, and options
in a set of files rather than typing them all by hand. By running autofs as a service that starts and
291
Need help?
Do you have a question about the LINUX 7.2 and is the answer not in the manual?
Questions and answers