-->
Previous Table of Contents Next


Understanding the /etc/exports File

The /etc/exports file is used by the mountd and nfsd daemons to determine what file systems are to be exported and what restrictions are placed on them. File systems are listed in /etc/exports, one per line. The format of each line is the name of the mount point for a local file system, followed by a list of computers that are allowed to mount this file system. A comma-separated list of mount options in parentheses may follow each name in the list. Table 14.5 lists the mount options available in the /etc/exports file.

Table 14.5 Mount Options Available in the /etc/exportsb File

Option Description

insecure Permits non-authenticated access from this machine.
secure Requires secure RPC authentication from this machine.
root_squash Maps any requests from root, UID 0 on the client, to the UID NOBODY_UID on the server.
no_root_squash Doesn’t map any requests from UID 0 (default behavior).
ro Mounts the file system as read-only (default behavior).
rw Mounts the file system as read-write.
link_relative Converts absolute symbolic links (where the link contents start with a slash) into relative links by prefixing the link with the necessary number of ../ characters to get from the directory containing the link to the root on the server.
link_absolute Leaves all symbolic links as they are (normal behavior for Sun NFS servers). This is the default behavior for Linux.
map_daemon Maps local and remote names and numeric IDs by using an lname/uid map daemon on the client where the NFS request originated. Used to map between the client and server UID spaces.
all-squash Maps all UIDs and GIDs to the anonymous user. This option is useful for NFS-exported public directories, such as those housing FTP and news.
no-all-squash The opposite of the all-squash option. This is the default option for Linux.
squash-uids Specifies a list of UIDs subject to anonymous mappings. A valid list of IDs looks like this:
squash uids=0-15,20,25-50
squash-gids Specifies a list of GIDs subject to anonymous mappings. A valid list of IDs looks like this:
squash gids=0-15,20,25-50
anonuid Sets the UID for the anonymous account. This option is useful for PC/NFS clients.
anongid Sets the GID for the anonymous account. This option is useful for PC/NFS clients.
noaccess Used to exclude certain subdirectories from a client. Makes everything below the directory inaccessible to the client.

Here is a sample /etc/exports file:


/home               bill.tristar.com(rw) fred.tristar.com(rw)

george.tristar.com(rw)

/usr/local/bin/bin          *.tristar.com(ro)

/projects           develop.tristar.com(rw) bill.tristar.com(ro)

/pub                (ro,insecure,root_squash)

In this example, the server exports four different file systems. /home is mounted with read/write access on three different computers: bill, fred, and george. This indicates the directory probably holds user home directories because of the directories’ names. The /usr/local/bin file system is exported as read-only with access allowed for every computer in the tristar.com domain.

The /projects file system is exported with read/write access for the computer develop.tristar.com but with read-only access for bill.tristar.com.

For the /pub file system, there’s no list of hosts that are allowed access. This means that any host is allowed to mount this file system. It has been exported as read-only with non-authenticated access allowed, and the server remaps any request from root on a remote machine that accesses this file system.

Mounting NFS File Systems

Mounting an NFS file system is similar to mounting any other type of file system. You can mount NFS file systems from the /etc/fstab file at boot time or interactively via the mount command.


CAUTION:  
You must be sure to separate the host name and file/system/path portions of the remote file system name with a colon, such as

mailserver:/var/spool/mail

when using the mount command or when making an entry in /etc/fstab. If you don’t separate the host name from the directory, your system won’t mount the remote directory correctly.


Mounting NFS File Systems via /etc/fstab

When you specify an NFS file system in the /etc/fstab file, you identify the file system with the format


hostname: /file/system path

where hostname is the name of the server where the file system is located, and /file/system/path is the file system on the server.

The file-system type is specified as nfs in the mount options field of the file system entry. Table 14.6 lists the most commonly used mount options.

Table 14.6 Commonly Used Options for NFS Mounts

Option Description

rsize=n Specifies the datagram size in bytes used by the NFS clients on read requests. The default value is 1,024 bytes.
wsize=n Specifies the datagram size in bytes used by the NFS clients on write requests. The default value is 1,024 bytes.
timeo=n Sets the time, in tenths of a second, that the NFS client waits for a request to complete. The default value is 0.7 seconds.
hard Mounts this file system by using a hard mount. This is the default behavior.
soft Mounts this file system by using a soft mount.
intr Allows signals to interrupt an NFS call. This is useful for aborting an operation when an NFS server doesn’t respond.


Previous Table of Contents Next