9.3. NFS Server Configuration

There are three ways to configure an NFS server under Red Hat Enterprise Linux: using the NFS Server Configuration Tool (redhat-config-nfs), manually editing its configuration file (/etc/exports), or using the /usr/sbin/exportfs command.

For instructions on using NFS Server Configuration Tool, refer to the chapter titled Network File System (NFS) in the Red Hat Enterprise Linux System Administration Guide. The remainder of this section discusses manually editing /etc/exports and using the /usr/sbin/exportfs command to export NFS file systems.

9.3.1. NFS Server Configuration File

The /etc/exports file controls which file systems are exported to remote hosts and specifies options. Blank lines are ignored, comments can be made by starting a line with the hash mark (#), and long lines can be wrapped with a backslash (\). Each exported file system should be on its own individual line, and any lists of authorized hosts placed after an exported file system must be separated by space characters. Options for each of the hosts must be placed in parentheses directly after the host identifier, without any spaces separating the host and the first parenthesis.

A line for an exported file system has the following structure:

<export> <host1>(<options>) <hostN>(<options>)...

In this structure, replace <export> with the directory being exported, replace <host1> with the host or network to which the export is being shared, and replace (<options> with the options for that host or network. Additional hosts can be specified in a space separated list.

The following methods can be used to specify host names:

In its simplest form, /etc/exports need only specify the exported directory and the hosts permitted to access it, as in the following example:

/exported/directory bob.example.com

In the example, bob.example.com can mount /exported/directory/. Because no options are specified in this example, the following default NFS options take effect:

ImportantImportant
 

By default, access control lists (ACLs) are supported by NFS under Red Hat Enterprise Linux. To disable this feature, specify the no_acl option when exporting the file system. For more about this feature, refer to the chapter titled Network File System (NFS) in the Red Hat Enterprise Linux System Administration Guide.

Each default for every exported file system must be explicitly overridden. For example, if the rw option is not specified, then the exported file system is shared as read-only. The following is a sample line from /etc/exports which overrides two default options:

/another/exported/directory 192.168.0.3(rw,sync)

In this example 192.168.0.3 can mount /another/exported/directory/ read/write and all transfers to disk are committed to the disk before the write request by the client is completed.

Additionally, other options are available where no default value is specified. These include the ability to disable sub-tree checking, allow access from insecure ports, and allow insecure file locks (necessary for certain early NFS client implementations). Refer to the exports man page for details on these lesser used options.

WarningWarning
 

The format of the /etc/exports file is very precise, particularly in regards to use of the space character. Remember to always separate exported file systems from hosts and hosts from one another with a space character. However, there should be no other space characters in the file except on comment lines.

For example, the following two lines do not mean the same thing:

/home bob.example.com(rw)
/home bob.example.com (rw)

The first line allows only users from bob.example.com read/write access to the /home directory. The second line allows users from bob.example.com to mount the directory read-only (the default), but the rest of the world can mount it read/write.

For detailed instructions on configuring an NFS server by editing /etc/exports, refer to the chapter titled Network File System (NFS) in the Red Hat Enterprise Linux System Administration Guide.

9.3.2. The exportfs Command

Every file system being exported to remote users via NFS, as well as the access level for those file systems, are listed in the /etc/exports file. When the nfs service starts, 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.

When issued manually, the /usr/sbin/exportfs command allows the root user to selectively export or unexport directories without restarting the NFS service. When passed the proper options, the /usr/sbin/exportfs command writes the exported file systems to /var/lib/nfs/xtab. Since rpc.mountd refers to the xtab file when deciding access privileges to a file system, changes to the list of exported file systems take effect immediately.

The following is a list of commonly used options available for /usr/sbin/exportfs:

If no options are passed to the /usr/sbin/exportfs command, it displays a list of currently exported file systems.

For more information about the /usr/sbin/exportfs command, refer to the exportfs man page.

mirror server hosted at Truenetwork, Russian Federation.