C++ CSS HTML Java JavaScript MySQL Oracle PERL PHP SQL Unix VBScript XHTML XML Сети
NFS Client Configuration Files
 

9.3. NFS Client Configuration Files

Any NFS share made available by a server can be mounted using various methods. The share can be manually mounted, using the mount command. However, this requires that the root user type the mount command every time the system restarts. Two methods of configuring NFS shares to be mounted automatically at boot time include modifying the /etc/fstab or using the autofs service.

9.3.1. /etc/fstab

Placing a properly formatted line in the /etc/fstab file has the same effect as manually mounting the exported file system. The /etc/fstab file is read by the /etc/rc.d/init.d/netfs script at system startup and any NFS shares listed there will be mounted.

A sample /etc/fstab line to mount an NFS export looks like the following:

<server>:</path/of/dir> </local/mnt/point> nfs <options> 0 0

The <server-host> corresponds to hostname, IP address, or fully qualified domain name of the server exporting the file system.

The </path/of/directory> is the path to the exported directory.

The </local/mount/point> specifies where on the local file system 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 file system being mounted.

The <options> area specifies mount options for the file system. For example, if the options area states rw,suidSection 9.3.3 Common NFS Mount Options.

9.3.2. autofs

One drawback to using /etc/fstab mounts, but when the 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 automount utility, which will mount and unmount NFS file systems automatically, saving resources.

The autofs script, located in the /etc/rc.d/init.d/ directory, is used to control automount through the /etc/auto.master primary configuration file. While automount running autofs as a service that starts and stops in designated runlevels, the mount configurations in the various files can be automatically implemented.

The autofs configuration files are arranged in a parent-child relationship. A main configuration file (/etc/auto.master) refers mount points on your system that are linked to a particular map type, which take the form of other configuration files, programs, NIS maps, and other less common mount methods. The auto.master file contains lines referring to each of these mount points, organized like this:

<mount-point>    <map-type>

The <mount-point> element of this line indicates the location of the mount on the local file system. The <map-type> usually named auto.<mount-point>, where <mount-point> is the mount point designated in auto.master, contains lines that look like this:

<directory>  <mount-options>  <host>:<exported-file-system>

The <directory> refers to the directory within the mount point where the exported file system should be mounted. Much like a standard mount command, the host exporting the file system, as well as the file system being exported, are required in the <host>:<exported-file system> section. To specify particular options to be used when mounting the exported file system, place them in the <mount-options> section, separated by commas. For NFS mounts that use autofs, place -fstype=nfs in the <mount-options> section.

While autofs a user's /home/ directory on a central server via an NFS share. Then, they configure the auto.master file on each of the workstations to point to an auto.home file containing the specifics for how to mount the /home/ directory via NFS. This allows the user to access personal data and configuration files in their /home/ directory by logging in anywhere on the internal network. The auto.master file in this situation would look similar to this:

/home   /etc/auto.home

This sets up the /home/ mount point on the local system to be configured by the /etc/auto.home file, which may look similar to this:

*  -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid  server.example.com:/home

This line states that any directory a user tries to access under the local /home/ directory (due to the asterisk character) should result in an NFS mount on the server.example.com system within its exported /home/ file system. The mount options specify that each /home/ directory NFS mounts should use a particular collection of settings. For more information on mount options, including the ones used in this example, see Section 9.3.3 Common NFS Mount Options.

9.3.3. Common NFS Mount Options

manual mount commands, /etc/fstab settings, and autofs, and other mounting methods.

The following options are the most popular for NFS mounts:

Many more options are listed on the mount man page, including options for mounting non-NFS file systems.

Главная