Autofs uses three types of maps:
The auto_master map associates a directory with a map. The map is a master list that specifies all the maps that autofs should check. The following example shows the types of information that an auto_master file could contain.Example 2-1 Sample /etc/auto_master File
# Master map for automounter # +auto_master /net -hosts -nosuid,nobrowse /home auto_home -nobrowse /nfs4 -fedfs -ro,nosuid,nobrowse /- auto_direct -ro
mount-point map-name [ mount-options ]
Full (absolute) path name of a directory. If the directory does not exist, autofs creates the directory if possible. If the directory exists and is not empty, mounting on the directory hides its contents. In this situation, autofs issues a warning.
The notation /- as a mount point indicates that this particular map is a direct map. The notation also means that no particular mount point is associated with the map.
Name of the map that autofs uses to find directions to locations, or mount information. If the name is preceded by a slash (/), autofs interprets the name as a local file. Otherwise, autofs searches for the mount information by using the search that is specified in the name-service switch configuration file (/etc/nsswitch.conf). Special maps are also used for /net. For more information, see Mount Point /net.
An optional, comma-separated list of options that apply to the mounting of the entries that are specified in map-name, unless the entries in map-name list other options. Options for each specific type of file system are listed in the mount man page for that file system. For information about NFS-specific mount options, see the mount_nfs (1M) man page. For NFS-specific mount points, the bg (background) and fg (foreground) options do not apply.
Autofs mounts under the directory /net all the entries in the special built-in map -hosts that uses only the hosts database. Suppose that the computer system1 is in the hosts database and it exports any of its file systems. The following command changes the current directory to the root directory of the computer gumbo.
# cd /net/gumbo
Autofs can mount only the exported file systems of host system1, that is, those file systems on a server that are available to network users instead of those file systems on a local disk. Therefore, all the files and directories on system1 might not be available through /net/system1.
With the /net method of access, the server name is in the path and is location dependent. If you want to move an exported file system from one server to another, the path might no longer work. Instead, you should set up an entry in a map specifically for the file system you want rather than using /net.
The /nfs4 mount point uses a pseudo-map to mount the FedFS domain root. A reference to the /nfs4/example.net file results in an attempt to find the domain root for the DNS domain example.net and mounts it at that location. Mounting a path under /nfs4 requires that the DNS server returns a record, as described in Set Up a DNS Record for a FedFS Server.
A direct map is an automount point. With a direct map, a direct association exists between a mount point on the client and a directory on the server. Direct maps have a full path name and indicate the relationship explicitly. The following example shows a typical /etc/auto_direct map:
/usr/local -ro \ /bin system1:/export/local/sun4 \ /share system1:/export/local/share \ /src system1:/export/local/src /usr/man -ro system2:/usr/man \ system3:/usr/man \ system4:/usr/man /usr/games -ro system5:/usr/games /usr/spool/news -ro system6:/usr/spool/news \ system4:/var/spool/news
key [ mount-options ] location
Path name of the mount point in a direct map.
Options that you want to apply to this particular mount. These options are required only if the options differ from the map default. Options for each specific type of file system are listed in the mount man page for that file system. For information about NFS specific mount options, see the mount_nfs (1M) man page.
Location of the file system. One or more file systems are specified as server:pathname for NFS file systems.
As in the master map, a line that begins with # is a comment. All the text that follows until the end of the line is ignored. Put a backslash at the end of the line to split long lines into shorter ones.
Of all the maps, the entries in a direct map most closely resemble the corresponding entries in /etc/vfstab. An entry might appear in /etc/vfstab as follows:
dancer:/usr/local - /usr/local/tmp nfs - yes ro
The equivalent entry appears in a direct map as follows:
/usr/local/tmp -ro dancer:/usr/local
For information about the features of direct autofs map, see How Autofs Selects the Nearest Read-Only Files for Clients (Multiple Locations).
In Example 2–1, the mount point /- tells autofs not to associate the entries in auto_direct with any specific mount point. Indirect maps use mount points that are defined in the auto_master file. Direct maps use mount points that are specified in the named map. Note that, in a direct map the key, or mount point, is a full path name.
An NIS auto_master file can have only one direct map entry because the mount point must be a unique value in the namespace. An auto_master file that is a local file can have any number of direct map entries if entries are not duplicated.
An indirect map uses a substitution value of a key to establish the association between a mount point on the client and a directory on the server. Indirect maps are useful for accessing specific file systems, such as home directories. The auto_home map is an example of an indirect map.
key [ mount-options ] location
Name without slashes in an indirect map.
Options that you want to apply to this particular mount. These options are required only if the options differ from the map default. Options for each specific type of file system are listed in the mount man page for that file system. For example, see the mount_nfs (1M) man page for NFS-specific mount options.
Location of the file system. One or more file systems are specified as server:pathname.
As in the master map, a line that begins with # is a comment. All the text that follows until the end of the line is ignored. Put a backslash (\) at the end of the line to split long lines into shorter ones. Example 2–1 shows an auto_master map that contains the following entry:
/home auto_home -nobrowse
user1 server1:/export/home/user1 user2 server2:/export/home/user2 user3 server3:/export/home/user3 user4 server4:/export/home/user4 user5 server5:/export/home/user5 user6 server6:/export/home/user6 user7 -rw,nosuid server7:/export/home/user7
As an example, assume that the previous map is on host master-server. Suppose that the user user7 has an entry in the password database that specifies her home directory as /home/user7. Whenever user7 logs in to computer master-server, autofs mounts the directory /export/home/user7 that resides on the computer server7. Her home directory is mounted read-write, nosuid.
Assume the following conditions occur: User user7's home directory is listed in the password database as /home/user7. Anybody, including user7, has access to this path from any computer that is set up with the master map referring to the auto_home map.
Under these conditions, user user7 can run login or rlogin on any of these computers and have her home directory mounted in place for her.
Furthermore, now user7 can also type the following command:
# cd ~user1
Autofs mounts user1's home directory for user7 (if all permissions allow).
On a network without a name service, you have to change all the relevant files (such as /etc/passwd) on all systems on the network to allow Linda access to her files. With NIS, make the changes on the NIS master server and propagate the relevant databases to the slave servers.