The behavior of the automounter is determined by a set of files called automounter maps. There are two main types of maps: indirect and direct. An indirect map is useful when you are mounting several file systems that will share a common pathname prefix. As we will see shortly, an indirect map can be used to manage the directory tree in /home. A direct map is used to mount file systems where each mount point does not share a common prefix with other mount points in the map. In this section, we will look at examples of each of these types of maps.
An additional map, called the master map, is used by the automounter to determine the names of the files corresponding to the direct and indirect maps.
The most common type of automounter maps are indirect maps, which correspond to “regularly” named file systems like /home, or /usr directory trees. Regularly named file systems share the same directory prefix. For example, the directories /home/jdoe and /home/sdoe are regularly named directories in the /home directory tree.
Normally, indirect maps are stored in the /etc directory, and are named with the convention auto_directory, where “directory” is the name of the directory prefix (without slashes) which the indirect map is responsible for. As an example, the indirect map responsible for the /home directory is usually named auto_home. An indirect map is made up of a series of entries in the following format:
directory options host:filesystem
Here “directory” is the relative pathname of a directory that will be appended to the name of the directory that is corresponding to this indirect map as specified in the master map file. (The master map is covered later in this section.) For “options,” you can use any of the mount options covered earlier in Chapter 23. To specify options, you will need to prefix the first option with a dash (–). If you do not need any extra options, you can omit the options entirely.
The final entry in the map contains the location of the NFS file system.
Here is an example of the indirect map that is responsible for the directories in /home:
# /etc/auto_home - home directory map for automounter jdoe orem:/store/home/jdoe sdoe orem:/store/home/sdoe kdoe -bg srv-ss10:/home/kdoe
Here the entries for jdoe, sdoe, and kdoe correspond to the directories /home/jdoe, /home/sdoe, and /home/kdoe, respectively. The first two entries indicate that the automounter should mount the directories /home/jdoe and /home/sdoe from the NFS server orem, while the last one specifies that the directory /home/kdoe should be mounted from the NFS server srv-ss10. The last entry also demonstrates the use of options.
Now that we have taken a look at an indirect map, let’s walk through what happens when you access a file on an NFS file system that is handled by the automounter. For example, consider the following command that accesses the file /home/jdoe/docs/book/ch17.doc:
$ more /home/jdoe/docs/book/ch17.doc
Since the directory /home/jdoe is automounted, the following steps are used by the automounter to allow you to access the file:
The automounter looks at the pathname and determines that the directory /home is controlled by the indirect map auto_home.
The automounter looks at the rest of the pathname for a corresponding entry in the auto_home map. In this case, it finds the matching entry jdoe.
Once a matching entry has been found, the automounter checks to see if the directory /home/jdoe is already mounted. If the directory is already mounted, you can directly access the file; otherwise, the automounter mounts this directory and then allows you to access the file.
When you use an indirect map, the automounter takes complete control of the directory corresponding to the indirect map. This means that no user, not even root, can create entries in a directory corresponding to an indirect map. For this reason, directories specified in an indirect map cannot be automounted on top of an existing directory. In this case, you need a special type of map known as a direct map. A direct map allows you to mix automounter mount points and normal directories in the same directory tree. The directories specified in a direct map have “non-regular” mount points, which simply mean that they do not share a common prefix.
A common use for direct maps is to allow for directories in the /usr directory tree to be automounted.
The direct map is normally stored in the file /etc/auto_direct. The format of this file is similar to the format of the indirect maps:
directory options host:filesystem
Here “directory” is the absolute pathname of a directory. For “options,” you can use any of the mount options covered earlier in this chapter. To specify options, you will need to prefix the first option with a dash (–). If you do not need any extra options, you can omit the options entirely. The final entry in the map contains the location of the NFS file system. Here is an example of the direct map that is responsible for some of the directories in /usr:
# /etc/auto_direct - Direct Automount map /usr/pubsw/man orem:/internal/opt/man /usr/doc orem:/internal/httpd/htdocs
When any files in the directories /usr/pubsw/man or /usr/doc are accessed, the automounter will automatically handle the mounting of these directories.
When the automounter first starts, it reads the file /etc/auto_master to determine where to find the direct and indirect map files. The auto_master file is known as the master map. Its contents consists of lines whose format is as follows:
Here, “directory” is the name of the directory that corresponds to the indirect map. For a direct map, this entry is /–. The “map” is the name of the map file in the /etc directory corresponding to the “directory” given in the first column. The following example shows a master map file for the direct and indirect maps given earlier in this section:
# Master map for automounter /home auto_home /- auto_direct
Other entries can also be made in the master map. For example, to share a common directory for mail between a number of clients and a mail server, we would enter the definition:
This creates a share called “auto_mail,” which makes mail on a single server accessible to all client machines upon request. Automounter permits two kinds of shares that can be defined by direct and indirect maps: a direct map is a set of arbitrary mount points that are listed together, while an indirect map mounts everything under a specific directory. For example, auto_home mounts user directories and all subdirectories underneath them.
If an automounted share is available on the server, then you should see its details being displayed in the /etc/mnttab file:
burbank:/var/mail /var/mail nfs nosuid,dev=2bc0012 951071258
Continuing with the example of auto_mail, as defined in the master map, a file /etc/auto_mail would have to contain the following entry:
denver# cat /etc/auto_mail /var/mail burbank:/var/mail
This ensures that the burbank server knows where to find the /var/mail directory physically, and that automount can mount the shared volume at will. Sometimes, the network load caused by mounting and unmounting home directories can lead to an increase in I/O load, and reduce the effective bandwidth of a network. For this reason, only volumes that need to be shared should be shared.
The timeout parameter for automount can be modified to extend its latency for mounting and unmounting directories.
You should be able to explain the differences between direct, indirect, and master maps for the exam.