HPlogo HP-UX Reference Volume 2 of 5 > a

automount(1M)

autofs and automounter
» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

automount — install automatic mount points (autofs) or automatically mount NFS file systems; see "Remarks" below in SYNOPSIS.

SYNOPSIS

/usr/sbin/automount [-f master-file] [-t duration] [-v]

Remarks

This manpage contains two versions of automount. The autofs version is presented first, followed by the previous automounter version.

The /usr/sbin/automount script checks the AUTOFS variable in /etc/rc.config.d/nfsconf. If the AUTOFS variable is set to one, then /usr/lib/netsvc/fs/autofs/automount is executed. The first half of this manpage represents the autofs automount.

If the AUTOFS variable is set to 0 (zero) or does not exist in /etc/rc.config.d/nfsconf, then the automount daemon is executed in /usr/lib/netsvc/fs/automount/automount. The second half of this manpage represents the older automount.

In future releases, only the autofs version of automount will be supported.

DESCRIPTION

automount is a command that installs autofs mount points and associates an automount map with each mount point. The autofs filesystem monitors attempts to access directories within it and notifies the automountd daemon (See automountd(1M)). The daemon uses the map to locate a filesystem, which it then mounts at the point of reference within the autofs filesystem. You can assign a map to an autofs mount using an entry in the /etc/auto_master map or a direct map.

If the file system is not accessed within an appropriate interval (five minutes by default), the automountd daemon unmounts the file system.

The file /etc/auto_master determines the locations of all autofs mount points. By default, this file contains the following entry:

# Master map for automounter # /net -hosts -soft

The first field in the master file specifies a directory on which an autofs mount will be made, and the second field specifies the automounter map to be associated with it. Mount options may be supplied as an optional third field in the entry. These options are used for any entries in the map that do not specify mount options explicitly. The automount command is usually run without arguments. It compares the entries /etc/auto_master with the current list of autofs mounts in /etc/mnttab and adds, removes or updates autofs mounts to bring the /etc/mnttab up to date with the /etc/auto_master. At boot time it installs all autofs mounts from the master map. Subsequently, it may be run to install autofs mounts for new entries in the master map or a direct map, or to perform unmounts for entries that have been removed.

The automounter maps, including the auto_master map, may be distributed by NIS or NIS+. The Name Service Switch configuration file, /etc/nsswitch.conf, determines where the automount command will look for the maps.

Options

-f master-file

Specify a local master file for initialization.

When the -f option is used and the master file specified is not found, then automount defaults to /etc/auto_master and then to the NIS auto_master map.

-t duration

Specify a duration, in seconds, that a file system is to remain mounted when not in use. The default is 5 minutes.

-v

Verbose mode. Notify of autofs mounts, unmounts or other non-essential information. Messages are written to stderr.

Map Entry Format

A simple map entry (mapping) takes the form:

  • key [ -mount-options ] location...

where key is the full pathname of the directory to mount when used in a direct map, or the simple name of a subdirectory in an indirect map. mount-options is a comma-separated list of mount options, and location specifies a file system from which the directory may be mounted. In the case of a simple NFS mount, location takes the form:

host:pathname

host is the name of the host from which to mount the file system (it may be omitted if the pathname refers to a local device on which the filesystem resides) and pathname is the pathname of the directory to mount.

Default mount options can be assigned to an entire map when specified as an optional third field in the master map. These options apply only to map entries that have no mount options.

Replicated Filesystems

Multiple location fields can be specified for replicated NFS filesystems, in which case automount chooses a server with preference given to a server on the local subnet or net.

If each location in the list shares the same pathname then a single location may be used with a comma-separated list of hostnames:

hostname,hostname...:pathname

The multiple location feature for NFS mounts allows the automountd daemon to choose the most appropriate server at mount time. While such a mount is in effect, the daemon does not monitor the status of the server. If the server crashes, automountd will not select an alternative server from the list.

Requests for a server may be weighted, with the weighting factor appended to the server name as an integer in parentheses. Servers without a weighting are assumed to have a value of zero (most likely to be selected). Progressively higher values decrease the chance of being selected. In the example,

man -ro alpha,bravo,charlie(1),delta(4):/usr/share/man

hosts alpha and bravo have the highest priority; host delta, has the lowest priority.

NOTE: Server proximity takes priority in the selection process. In the example above, if the server delta is on the same network segment as the client, but the others are on different network segments, then delta will be selected — the weighting value is ignored. The weighting has effect only when selecting between servers with the same network proximity.

In cases where each server has a different export point, you can still apply the weighting. For example:

man -ro alpha:/usr/man bravo,charlie(1):/usr/share/man delta(3):/export/man

A mapping can be continued across input lines by escaping the NEWLINE with a `\' (backslash). Comments begin with a '#' (number sign) and end at the subsequent NEWLINE.

Map Key Substitution

The '&' (ampersand) character is expanded to the value of the key field for the entry in which it occurs. In this case:

amy rowboatserver:/home/&

the & expands to amy.

Wildcard Key

The '*' (asterisk) character, when supplied as the key field, is recognized as the catch-all entry. Such an entry will match any key not previously matched. For instance, if the following entry appeared in the indirect map for /config:

* &:/export/config/&

this would allow automatic mounts in /config of any remote file system whose location could be specified as:

hostname:/export/config/hostname

Variable Substitution

Client specific variables can be used within an automount map. For instance, if $HOST appeared within a map, automount would expand it to its current value for the client's host name. Supported variables are:

HOST

The output of uname -n. The host name. For example "rowboat"

OSNAME

The output of uname -s. The OS name. For example "HP-UX"

OSREL

The output of uname -r. The OS release name. For example "B.11.0"

OSVERS

The output of uname -v. The OS version. For example "C"

If a reference needs to be protected from affixed characters, you can surround the variable name with '{}' (curly braces).

Multiple Mounts

A multiple mount entry takes the form:

  • key [- mount-options] [[mountpoint] [- mount-options] location...]...

The initial /[mountpoint] is optional for the first mount and mandatory for all subsequent mounts. The optional mountpoint is taken as a pathname relative to the directory named by key. If mountpoint is omitted in the first occurrence, a mountpoint of / (root) is implied.

Given an entry in the indirect map for /src:

beta -ro / svr1,svr2:/export/src/beta /1.0 svr1,svr2:/export/src/beta/1.0 /1.0/man svr1,svr2:/export/src/beta/1.0/man

automount would automatically mount /src/beta, /src/beta/1.0, and /src/beta/1.0/man, as needed, from either svr1 or svr2, whichever host is nearest and responds first.

The autofs mount points must not be hierarchically related. automount does not allow an autofs mount point to be created within another autofs mount.

Other Filesystem Types

The automounter assumes NFS mounts as a default filesystem type. Other filesystem types can be described using the fstype mount option. Other mount options specific to this filesystem type can be combined with the fstype option. The location field must contain information specific to the filesystem type. If the location field begins with a slash, a colon character must be prepended, for instance, to mount a CD filesystem:

  • cdrom -fstype=hsfs,ro :/dev/sr0

or to perform an autofs mount:

src -fstype=autofs auto_src

Mounts using CacheFS are most useful when applied to an entire map as map defaults (see cfsadmin(1M)). The following entry in the master map describes cached home directory mounts. It assumes the default location of the cache directory, /cache.

/home auto_home -fstype=cachefs,backfstype=nfs

Indirect Maps

An indirect map allows you to specify mappings for the subdirectories you wish to mount under the directory indicated in the /etc/auto_master map or on the command line. In an indirect map, each key consists of a simple name that refers to the subdirectory where one or more filesystems that are to be mounted as needed.

Entries in both direct and indirect maps can be modified at any time. The new information is used when automountd next uses the map entry to do a mount.

Direct Maps

Entries in a direct map are associated directly with autofs mount points. Each key is the full pathname of an autofs mount point. The direct map as a whole is not associated with any single directory.

Since each direct map entry results in a new autofs mount, such maps should be kept short.

If a directory contains direct map mount points, then an ls -l in the directory will force all the direct map mounts to occur.

Entries in both direct and indirect maps can be modified at any time. The new information is used when automountd next uses the map entry to do a mount.

New entries added to a master map or direct map will not be useful until the automount command is run to install them as new autofs mount points. New entries added to an indirect map may be used immediately.

An autofs directory associated with an indirect map shows only currently-mounted entries. This is a deliberate policy to avoid inadvertent mounting of every entry in a map via an ls -l of the directory.

Included Maps

The contents of another map can be included within a map with an entry of the form:

+mapname

If mapname begins with a slash then it is assumed to be the pathname of a local file. Otherwise the location of the map is determined by the policy of the name service switch according to the entry for the automounter in /etc/nsswitch.conf, such as

automount: nis files

If the name service is files then the name is assumed to be that of a local file in /etc. If the key being searched for is not found in the included map, the search continues with the next entry.

Special Maps

There are two special maps available: -hosts and -null. The -hosts map is used with the /net directory and assumes that the map key is the hostname of an NFS server. The automountd daemon dynamically constructs a map entry from the server's list of exported filesystems. For instance, a reference to /net/hermes/usr would initiate an automatic mount of all exported file systems from hermes that are mountable by the client. References to a directory under /net/hermes will refer to the corresponding directory relative to hermes root.

The -hosts map must mount all of the exported NFS filesystems from a server. If frequent access to just a single filesystem is required, it is more efficient to access the filesystem with a map entry that is tailored to mount just the filesystem of interest.

The -null map, when indicated on the command line, cancels a previous map for the directory indicated. This is most useful in the /etc/auto_master map for cancelling entries that would otherwise be inherited from the +auto_master include entry. To be effective, the -null entries must be inserted before the included map entry.

Executable Maps

Local maps that have the execute bit set in their file permissions will be executed by the automounter and provided with a key to be looked up as an argument. The executable map is expected to return the content of an automounter map entry on its stdout or no output if the entry cannot be determined.

Configuration and the auto_master Map

When initiated without arguments, automount consults the master map for a list of autofs mount points and their maps. It mounts any autofs mounts that are not already mounted, and unmounts autofs mounts that have been removed from the master map or direct map.

The master map is assumed to be called auto_master and its location is determined by the name service switch policy. Normally the master map is located initially as a local file, /etc/auto_master.

Network Information Service (NIS) and Yellow Pages (YP)

The Network Information Service (NIS) was formerly known as Sun Yellow Pages (YP). The functionality of the two remains the same.

EXIT STATUS

automount returns:

  • 0 successful

  • 1 failure

  • 3 map not found

AUTHOR

automount was developed by Sun Microsystems, Inc.

FILES

/etc/auto_master

master automount map.

/etc/nsswitch.conf

name service switch configuration file.

/usr/lib/netsvc/fs/autofs/automount

autofs automount command.

/usr/sbin/automount

previous automounter automount command.

SEE ALSO

automountd(1M), cfsadmin(1M), mount(1M).

NAME (HP-UX)

automount - automatically mount NFS file systems. This manpage contains two versions of automount. See "Remarks" below in SYNOPSIS.

SYNOPSIS (HP-UX)

automount [-nTv] [-D name = value] [-f master-file] [-M mount-directory] [-tl duration]

  • [-tm interval] [-tw interval] [directory map [-mount-options] ] ...

Remarks

This manpage contains two versions of automount. The autofs version is presented first, followed by the previous automounter version.

The /usr/sbin/automount script checks the AUTOFS variable in /etc/rc.config.d/nfsconf. If the AUTOFS variable is set to one, then /usr/lib/netsvc/fs/autofs/automount is executed. The first half of this manpage represents the autofs automount.

If the AUTOFS variable is set to 0 (zero) or does not exist in /etc/rc.config.d/nfsconf, then the automount daemon is executed in /usr/lib/netsvc/fs/automount/automount. The second half of this manpage represents the older automount.

In future releases, only the autofs version of automount will be supported.

DESCRIPTION

automount is a daemon that automatically and transparently mounts NFS file systems as needed. It monitors attempts to access directories that are associated with an automount map, along with any directories or files that reside under them. When a file is to be accessed, the daemon mounts the appropriate NFS file system. Maps can be assigned to a directory by using an entry in a direct automount map, or by specifying an indirect map on the command line.

automount interacts with the kernel in a manner closely resembling an NFS server:

  • automount uses the map to locate an appropriate NFS file server, exported file system, and mount options.

  • It then mounts the file system in a temporary location, and replaces the file system entry for the directory or subdirectory with a symbolic link to the temporary location.

  • If the file system is not accessed within an appropriate interval (five minutes by default), the daemon unmounts the file system and removes the symbolic link.

  • If the specified directory has not already been created, the daemon creates it, and then removes it upon exiting.

Since name-to-location binding is dynamic, updates to an automount map are transparent to the user. This obviates the need to mount shared file systems prior to running applications that contain internally hard-coded references to files.

If the dummy directory (/-) is specified, automount treats the map argument that follows as the name of a direct map. In a direct map, each entry associates the full path name of a mount point with a remote file system to mount.

If the directory argument is a path name, the map argument points to an indirect map. An indirect map, contains a list of the subdirectories contained within the indicated directory. With an indirect map, it is these subdirectories that are mounted automatically.

A map can be a file or a NIS/NIS+ map; if a file, the map argument must be a full path name.

The -mount-options argument, when supplied, is a comma-separated list of options to the mount command (see mount(1M)) preceded by a -. However, any conflicting mount options specified in the indicated map take precedence.

Options

automount recognizes the following options:

-m

Option not supported.

-n

Disable dynamic mounts. With this option, references through the automount daemon succeed only when the target filesystem has been previously mounted. This can be used to prevent NFS servers from cross-mounting each other.

-T

Trace. Expand each NFS call and log it in /var/adm/automount.log file.

-v

Verbose. Log status messages to the system log file (see syslogd(1M)).

-D envar = value

Assign value to the indicated automount (environment) variable envar.

-f master-file

Read the local master_file before reading auto_master map.

-M mount-directory

Mount temporary file systems in the named directory instead of in /tmp_mnt.

-tl duration

Specify a duration (in seconds) that a file system is to remain mounted when not in use. The default is 5 minutes.

-tm interval

Specify an interval (in seconds) between attempts to mount a filesystem. The default is 30 seconds.

-tw interval

Specify an interval (in seconds) between attempts to unmount filesystems that have exceeded their cached times. The default is 1 minute.

Map Entry Format

A simple map entry (mapping) takes the form:

directory [-mount-options] location ...

where directory is the full path name of the directory to mount, when used in a direct map, or the basename of a subdirectory in an indirect map. mount-options is a comma-separated list of mount options, and location specifies a remote filesystem from which the directory may be mounted. In the simple case, location takes the form:

host:pathname

Multiple location fields can be specified, in which case automount pings all servers in the list and then selects the first host that responds to serve that mount point.

If location is specified in the form:

host:path:subdir

host is the name of the host from which to mount the file system, path is the path name of the directory to mount, and subdir, when supplied, is the name of a subdirectory to which the symbolic link is made. This can be used to prevent duplicate mounts when multiple directories in the same remote file system might be accessed. Assume a map for /home resembling:

mike hpserver1:/home/hpserver1:mike dianna hpserver1:/home/hpserver1:dianna

Attempting to access a file in /home/mike causes automount to mount hpserver1:/home/hpserver1 and creates a symbolic link called /home/mike to the mike subdirectory in the temporarily-mounted filesystem. A subsequent file access request in /home/dianna results in automount simply creating a symbolic link that points to the dianna subdirectory because /home/hpserver1 is already mounted. Given the map:

mike hpserver1:/home/hpserver1/mike dianna hpserver1:/home/hpserver1/dianna

automount would have to mount the filesystem twice.

A mapping can be continued across input lines by escaping the newline character with a backslash (\). Comments begin with a # and end at the subsequent newline character.

Directory Pattern Matching

The & character is expanded to the value of the directory field for the entry in which it occurs. Given an entry of the form:

mike hpserver1:/home/hpserver1:&

the & expands to mike.

The * character, when supplied as the directory field, is recognized as the catch-all entry. Such an entry resolves to any entry not previously matched. For example, if the following entry appeared in the indirect map for /home:

* &:/home/&

this would allow automatic mounts in /home of any remote file system whose location could be specified as:

  • hostname :/home hostname

Hierarchical Mappings

A hierarchical mapping takes the form:

directory[/[subdirectory][-mount-options] location ...] ...

The initial / within the /[subdirectory] is required; the optional subdirectory is taken as a file name relative to the directory. If subdirectory is omitted in the first occurrence, the / refers to the directory itself.

Given the direct map entry:

/usr/local \ / -ro,intr shasta:/usr/local ranier:/usr/local \ /bin -ro,intr ranier:/usr/local/bin shasta:/usr/local/bin \ /man -ro,intr shasta:/usr/local/man ranier:/usr/local/man

automount automatically mounts /usr/local, /usr/local/bin, and /usr/local/man, as needed, from either shasta or ranier, whichever host responded first.

Direct Maps

A direct map contains mappings for any number of directories. Each directory listed in the map is automatically mounted as needed. The direct map as a whole is not associated with any single directory.

Indirect Maps

An indirect map allows specifying mappings for the subdirectories to be mounted under the directory indicated on the command line. It also obscures local subdirectories for which no mapping is specified. In an indirect map, each directory field consists of the basename of a subdirectory to be mounted as needed.

Included Maps

The contents of another map can be included within a map with an entry of the form:

+mapname

mapname can either be a file name, or the name of an NIS/NIS+ map, or one of the special maps described below. If mapname begins with a slash then it is assumed to be the pathname of a local file. Otherwise the location of the map is determined by the policy of the name service switch according to the entry for the automounter in /etc/nsswitch.conf, such as

  • automount: nis files

If the name service is files then the name is assumed to be that of a local file in /etc. If the key being searched for is not found in the included map, the search continues with the next entry.

Special Maps

Three special maps, -hosts, -passwd, and -null, are currently available: The -hosts map uses the gethostbyname() map to locate a remote host when the hostname is specified (see gethostent(3N)). This map specifies mounts of all exported file systems from any host. For example, if the following automount command is already in effect:

automount /net -hosts

a reference to /net/hermes/usr initiates an automatic mount of all file systems from hermes that automount can mount, and any subsequent references to a directory under /net/hermes refer to the corresponding directory on hermes. The -passwd map uses the passwd(4) database to attempt to locate a user's home directory. For example, if the following automount command is already in effect:

automount /homes -passwd

if the home directory for a user has the form /dir/server/username, and server matches the host system on which that directory resides, automount mounts the user's home directory as: /homes /username.

For this map, the tilde character (~) is recognized as a synonym for username.

The -null map, when indicated on the command line, cancels a previous map for the directory indicated. It can be used to cancel a map given in auto_master.

Configuration and the auto_master Map

automount normally consults the auto_master configuration map for a list of initial automount maps, and sets up automatic mounts for them in addition to those given on the command line. If there are duplications, the command-line arguments take precedence. This configuration database contains arguments to the automount command rather than mappings.

Maps given on the command line, or those given in a local master file specified with -f override those in the auto_master map. For example, given the command:

automount /homes /etc/auto.homes /- /etc/auto.direct

and the master map file auto_master containing:

/homes -passwd

automount mounts home directories using the /etc/auto.homes map instead of the special -passwd map in addition to the various directories specified in the /etc/auto.direct map.

EXTERNAL INFLUENCES

Environment Variables

Environment variables can be used within an automount map. For example, if $HOME appears within a map, automount expands it to the current value of the HOME environment variable.

To protect a reference from affixed characters, surround the variable name with curly braces. Environment variables cannot appear as the key entry in maps.

WARNINGS

Do not send the SIGKILL signal (kill -9, or kill -KILL) to the automount daemon. Doing so causes any processes accessing mount directories served by automount to hang. A system reboot may be required to recover from this state.

Do not start an automount daemon while another is still running. If restarting automount, make sure the first daemon and all of its children are not running.

When automount receives signal SIGHUP, it rereads the /etc/mnttab file to update its internal record of currently mounted file systems. If a file system mounted by automount is unmounted by a umount command, automount should be forced to reread the file by sending the SIGHUP signal (see kill(1)).

Shell file name expansion does not apply to objects not currently mounted.

Since automount is single-threaded, any request that is delayed by a slow or nonresponding NFS server delays all subsequent automatic mount requests until it completes.

Programs that read /etc/mnttab and then touch files that reside under automatic mount points introduce further entries to the file.

Automatically-mounted file systems are mounted with type ignore; they do not appear in the output of either mount or bdf (see mount(1M) and bdf(1M)).

AUTHOR

automount was developed by Sun Microsystems, Inc.

FILES

/tmp_mnt

directory under which filesystems are dynamically mounted

/etc/mnttab

mount table

/etc/nsswitch.conf

the name service switch configuration file.

© Hewlett-Packard Development Company, L.P.