11.1 NFS Services

11.2 Planning, Installation, and Configuration of NFS

There are no specific installation tasks needed for NFS as the Base Operating System (BOS) Installation also includes the default installation of network services, such as TCPIP and NFS.

Before starting the configuration of NFS on any of the systems, perform the following tasks:

  1. Identify which systems in the network will be servers and which will be clients (a system can be configured as both a server and a client). As shown in Figure 101, CRoom and Accounts are servers, and HResources and Marketing are clients. Note that Accounts is both a client and server.

  2. Start the NFS daemons for each system (whether client or server). The NFS daemons, by default, are not started on a newly installed system. When a system is first installed, all of the files are placed on the system, but the steps to activate NFS are not taken. The daemons can be started by:

# mknfs -N
0513-059 The portmap Subsystem has been started. Subsystem PID is 23734.
Starting NFS services:
0513-059 The biod Subsystem has been started. Subsystem PID is 27264.
0513-059 The nfsd Subsystem has been started. Subsystem PID is 30570.
0513-059 The rpc.mountd Subsystem has been started. Subsystem PID is 28350.
0513-059 The rpc.statd Subsystem has been started. Subsystem PID is 15298.
0513-059 The rpc.lockd Subsystem has been started. Subsystem PID is 30976.

Table 34 lists the most common flags of the mknfs command.

Table 34: Flags for the mknfs Command

The -B and -l options place an entry in the inittab file so that the /etc/rc.nfs script is run each time the system restarts. This script, in turn, starts all NFS daemons required for a particular system.

For each system that is to be a server (CRoom and Accounts), use the following instructions to configure them as NFS Server:

  1. Start the NFS daemons using SRC if not already started.

    The NFS daemons can be started individually or all at once. To start NFS daemons individually:

    startsrc -s daemon

    where daemon is any one of the SRC controlled daemons (See 11.4 NFS Files, Commands, and Daemons Reference). For example, to start the nfsd daemon:

    startsrc -s nfsd

    To start all of the NFS daemons:

    startsrc -g nfs


    If the /etc/exports file does not exist, the nfsd and the rpc.mountd daemons will not be started. You can create an empty /etc/exports file by running the command touch /etc/exports. This will allow the nfsd and the rpc.mountd daemons to start although no file systems will be exported.

  2. Create the exports in the /etc/exports file.

11.2.1 Exporting NFS

This section discusses the use of the exportfs command. Export an NFS Using SMIT

In order to export file systems using SMIT, follow this procedure:

  1. Verify that NFS is already running on CRoom and Accounts servers by entering the command lssrc -g nfs. As in the following example, the output should indicate that the nfsd and the rpc.mountd daemons are active. If they are not, start NFS using the instructions in 11.2 Planning, Installation, and Configuration of NFS.
    # lssrc -g nfs
    Subsystem         Group            PID     Status
     biod             nfs              15740   active
     nfsd             nfs              11376   active
     rpc.mountd       nfs              5614    active
     rpc.statd        nfs              16772   active
     rpc.lockd        nfs              15496   active

  2. Use smitty mknfsexp to export the directory; the SMIT screen is as shown in Figure 102.

    Figure 102: Adding a Directory to Export List

  3. For CRoom Server, specify /home1, and on Accounts /backup in the PATHNAME of directory to export field, set read-write MODE to export directory, and set both for EXPORT directory now, system restart, or both fields.

  4. Specify any other optional characteristics you want or accept the default values by leaving the remaining fields as they are. For this illustration, for Accounts, set the Hosts and NetGroups allowed client access field to Marketing and keep the default for everything else.

  5. When you have finished making your changes, SMIT updates the /etc/exports file. If the /etc/exports file does not exist, then it will be created.

  6. Repeat steps 3 through 5 for directories /home2, /home3, /home4 on CRoom. Accounts is only exporting /backup; so, there is no need to do any other exports.

  7. If NFS is currently running on the servers, enter:

    /usr/sbin/exportfs -a

    The -a option tells the exportfs command to send all information in the /etc/exports file to the kernel. If NFS is not running, start NFS using the instructions in 11.2 Planning, Installation, and Configuration of NFS.

  8. Verify that all file systems have been exported properly as follows:

    For the CRoom Server:

    # showmount -e CRoom
    export list for CRoom:
    /home1     (everyone)
    /home2     (everyone)
    /home3     (everyone)
    /home4     (everyone)

    For the Accounts Server:

    # showmount -e Accounts
    export list for Accounts:
    /backup Marketing
    # To Export an NFS Using a Text Editor

In order to export file systems using a text editor, follow this procedure:

  1. Open the /etc/exports file with your favorite text editor.

    vi /etc/exports

  2. Create an entry for each directory to be exported using the full path name of the directory as shown in Figure 103. .

    Figure 103: Content of /etc/exports for CRoom Server

  3. List each directory to be exported starting in the left margin. No directory should include any other directory that is already exported. Save and close the /etc/exports file. Export an NFS Temporarily

A file system can be exported when needed, and as such, does not change the /etc/exports file. This is done by entering:

exportfs -i /dirname

where dirname is the name of the file system you want to export. The exportfs -i command specifies that the /etc/exports file is not to be checked for the specified directory, and all options are taken directly from the command line.

For each system that is to be a client (HResources, Accounts, and Marketing), the following steps will ensure that they have access to directories and files on the CRoom and Accounts Servers.

  1. Verify that NFS is the default remote file system. If this is not done, you will need to specify the -v nfs flag when using the mount command. Using a text editor, open the /etc/vfs file and search for the following entries:
    %defaultvfs jfs nfs
    nfs 2 /sbin/helpers/nfsmnthelp none remote

    If pound signs (#) appear at the beginning of the lines as shown, delete the pound signs.

  2. Save and close the /etc/vfs file.

  3. Start NFS using the instructions in 11.2 Planning, Installation, and Configuration of NFS.

  4. Go to 11.2.3 Mounting an NFS.

11.2.2 Unexporting an NFS

You can unexport an NFS directory using one of the following procedures.

11.2.3 Mounting an NFS

There are three types of NFS mounts: Predefined, explicit, and automatic.

Predefined mounts are specified in the /etc/filesystems file. Each stanza (or entry) in this file defines the characteristics of a mount as shown in Figure 104. Data, such as the host name, remote path, local path, and any mount options, are listed in this stanza. Predefined mounts should be used when certain mounts are always required for proper operation of a client.

dev       = /dev/hd1
vol       = "/home1"
mount     = true
check     = true
free      = false
vfs       = jfs
log       = /dev/hd8
Figure 104: Example of a Stanza in the /etc/filesystems File

Explicit mounts serve the needs of the root user. Explicit mounts are usually done for short periods of time when there is a requirement for occasional unplanned mounts. Explicit mounts can also be used if a mount is required for special tasks, and that mount should not be generally available on the NFS client. These mounts are usually fully qualified on the command line by using the mount command with all needed information.

Explicit mounts do not require updating the /etc/filesystems file. File systems mounted explicitly remain mounted unless explicitly unmounted with the umount command or until the system is restarted.

Automatic mounts are controlled by the automount command, which causes the AutoFS kernel extension to monitor specified directories for activity. If a program or user attempts to access a directory that is not currently mounted, then AutoFS intercepts the request, arranges for the mount of the file system, and then services the request. NFS Mounting Process

Clients access files on the server by first mounting a server's exported directories. When a client mounts a directory, it does not make a copy of that directory. Rather, the mounting process uses a series of remote procedure calls to enable a client to access the directories on the server transparently. The following describes the mounting process:

  1. When the server starts, the /etc/rc.nfs script runs the exportfs command, which reads the server /etc/exports file and then tells the kernel which directories are to be exported and which access restrictions they require.

  2. The rpc.mountd daemon and several nfsd daemons (eight, by default) are then started by the /etc/rc.nfs script.

  3. When the client starts, the /etc/rc.nfs script starts several biod daemons (eight, by default), which forward client mount requests to the appropriate server.

  4. Then the /etc/rc.nfs script executes the mount command, which reads the file systems listed in the /etc/filesystems file.

  5. The mount command locates one or more servers that export the information the client wants and sets up communication between itself and that server. This process is called binding.

  6. The mount command then requests that one or more servers allow the client to access the directories in the client /etc/filesystems file.

  7. The server rpc.mountd daemon receives the client mount requests and either grants or denies them. If the requested directory is available to that client, the rpc.mountd daemon sends the client's kernel an identifier called a file handle.

  8. The client kernel then ties the file handle to the mount point (a directory) by recording certain information in a mount record.

Once the file system is mounted, the client can perform file operations. When the client does a file operation, the biod daemon sends the file handle to the server, where the file is read by one of the nfsd daemons to process the file request. Assuming the client has access to perform the requested file operation, the nfsd daemon returns the necessary information to the client's biod daemon.

The following procedure helps to complete the scenario shown in Figure 101.

  1. On HResources, establish the local mount point for /home1 on server CRoom using the mkdir command.

    mkdir /home1

    This directory should be empty. This mount point can be created like any other directory, and no special attributes are needed for this directory.


    The mount points for all NFS mounts must exist on your system before you can mount a file system with one exception. If the automount daemon is used, it may not be necessary to create mount points. See Mounting an NFS Automatically.

  2. On HResources, establish and mount the predefined mounts by following the instructions in Establishing Predefined NFS Mounts. Establishing Predefined NFS Mounts

You can establish predefined NFS mounts using one of the following procedures.


Define the bg (background) and intr (interruptible) options in the /etc/filesystems file when establishing a predefined mount that is to be mounted during system startup. Mounts that are non-interruptible and running in the foreground can hang the client if the network or server is down when the client system starts up. If a client cannot access the network or server, the user must start the machine again in maintenance mode and edit the appropriate mount requests.

To establish predefined mounts through SMIT (Figure 105), use the following command:

smitty mknfsmnt

Figure 105: Adding a File System for Mounting

Specify values in this screen for each mount you want predefined. You must specify a value for each required field (those marked with an asterisk (*) in the left margin). You may specify values for the other fields or accept their default values. This method creates an entry in the /etc/filesystems file for the desired mount and attempts the mount.

To establish the NFS default mounts by editing the /etc/filesystems file (only use this method under special circumstances), perform the following:

  1. Open the /etc/filesystems file on HResources with a text editor. Add entries for each of the remote file systems that you want mounted when the system is started. For example:
    dev = /home1
    mount = false
    vfs = nfs
    nodename = CRoom
    options = ro,soft
    type = nfs_mount

    This stanza directs the system to mount the /home1 remote directory over the local mount point of the same name. The file system is mounted as read-only (ro). Because it is also mounted as soft, an error is returned in the event the server does not respond. By specifying the type parameter as nfs_mount, the system attempts to mount the /home1 file system (along with any other file systems that are specified in the type = nfs_mount group) when the mount -t nfs_mount command is issued.

    The following example stanza directs the system to mount the /home2 file system at system startup time. If the mount fails, the system continues to attempt to mount in the background.

    dev = /home2
    mount = true
    vfs = nfs
    nodename = CRoom
    options = ro,soft,bg
    type = nfs_mount


    See Parameters for additional parameters.

  2. Remove any directory entries that you do not want to mount automatically at system startup.

  3. Save and close the file.

  4. Run the mount -a command to mount all the directories specified in the /etc/filesystems file.

  5. On Marketing, repeat mount for /backup directory from Accounts

The NFS is now ready to use. Mounting an NFS Explicitly

To mount an NFS directory explicitly, use the following procedure:

  1. Verify that the NFS server has exported the directory, using:
    showmount -e ServerName

    For Server CRoom:

    # showmount -e CRoom
    export list for CRoom:
    /home1     (everyone)
    /home2     (everyone)
    /home3     (everyone)
    /home4     (everyone)

    where ServerName is the name of the NFS server. This command displays the names of the directories currently exported from the NFS server. If the directory you want to mount is not listed, export the directory from the server.

  2. Establish the local mount point using the mkdir command. For NFS to complete a mount successfully, a directory that acts as the mount point (or place holder) of an NFS mount must be present. This directory should be empty. This mount point can be created like any other directory, and no special attributes are needed for this directory.

  3. On the HResources machine, enter the following SMIT fast path:

    smitty mknfsmnt

  4. Make changes to the following fields that are appropriate for your network configuration. Your configuration may not require completing all of the entries on this screen.


    If you are using the ASCII SMIT interface, press the Tab key to change to the correct value for each field, but do not press Enter until you get to step 7.

  5. Use the default values for the remaining entries or change them depending on your NFS configuration.

  6. When you finish making all the changes on this screen, SMIT mounts the NFS.

  7. When the Command: field shows the OK status, exit SMIT.

The NFS is now ready to use. Mounting an NFS Automatically

AutoFS relies on the use of the automount command to propagate the automatic mount configuration information to the AutoFS kernel extension and start the automountd daemon. Through this configuration propagation, the extension automatically and transparently mounts file systems whenever a file or a directory within that file system is opened. The extension informs the automountd daemon of mount and unmount requests, and the automountd daemon actually performs the requested service.

Because the name-to-location binding is dynamic within the automountd daemon, updates to a Network Information Service (NIS) map used by the automountd daemon are transparent to the user. Also, there is no need to pre-mount shared file systems for applications that have hard-coded references to files and directories, nor is there a need to maintain records of which hosts must be mounted for particular applications.

AutoFS allows file systems to be mounted as needed. With this method of mounting directories, all file systems do not need to be mounted all of the time, only those being used are mounted.

For example, to mount the /backup NFS directory automatically:

  1. Verify that the NFS server has exported the directory by entering:
    # showmount -e Accounts
    export list for Accounts:
    /backup Marketing

    This command displays the names of the directories currently exported from the NFS server.

  2. Create an AutoFS map file. AutoFS will mount and unmount the directories specified in this map file. For example, suppose you want to use AutoFS to mount the /backup directory as needed from the Accounts server onto the remote /backup directory. In this example, the map file name is /tmp/mount.map.

  3. Ensure that the AutoFS kernel extension is loaded and the automountd daemon is running. This can be accomplished in two ways:
    1. Using SRC, enter:
      lssrc -s automountd

      If the automountd subsystem is not running, issue: startsrc -s automountd

    2. Using the automount command, issue /usr/sbin/automount -v. Define the map file using the command line interface by entering:
      /usr/sbin/automount -v /backup /tmp/mount.map

      where /backup is the AutoFS mount point on the client. Now, if a user runs the cd /backup command, the AutoFS kernel extension will intercept access to the directory and will issue a remote procedure call to the automountd daemon, which will mount the /backup directory and then allow the cd command to complete.

  4. To stop the automountd, issue the stopsrc -s automountd command.

    If, for some reason, the automountd daemon was started without the use of SRC, issue:

    kill automountd_PID

    where automountd_PID is the process ID of the automountd daemon. (Running the ps -e command will display the process ID of the automountd daemon.) The kill command sends a SIGTERM signal to the automountd daemon. Parameters

The parameters required for stanzas pertaining to NFS mounts are:

Specifies the path name of the remote file system being mounted.
If true, specifies that the NFS will be mounted when the system boots. If false, the NFS will not be mounted when the system boots.
Specifies the host machine on which the remote file system resides.
Specifies that the virtual file system being mounted is an NFS.

If you do not set the following options, the kernel automatically sets them to the following default values:

11.3 Administration of NFS Servers and Clients