Notes on the automounter
Contents
Wanting to make it easier (and faster) to access archival data stored in /var/local
on penguin, I set up an automounter on sparrow.
The automount master map: /etc/auto.master
The master map lists autofs-controlled mount points on the system, and their corresponding configuration files or network sources known as automount maps. The format of the master map is as follows:
mount-point map-name options
These options are:
mount-point
- The
autofs
mount point; for example,/home
. map-name
- The name of a map source which contains a list of mount points, and the file
system location from which those mount points should be mounted. Map source
types are prefixed with
type:
, where type is one offile:
(the default, so it doesn’t need to be specified,)program: (or exec:), yp:, nisplus:, hesiod, ldap:/ldaps:, multi:
ordir:
. Consult the theauto.master(5)
man page for a full description of these types. options
- If supplied, these applies to all entries in the given map provided they do
not themselves have options specified. This behavior is different from
autofs
version 4 where options were cumulative. This has been changed to implement mixed environment compatibility.
An alternative to updating /etc/auto.master
for every new mount point is to
create a file ending with .autofs
in /etc/auto.master.d
. The file can
contain one or more master entries.
mount-point map files
If map-name
refers to a file, the file contains information for mounting
devices such as partitions or NFS exports over one or more mount points under
the mount-point
named in the master map. For example, if the master map
contains:
/home /etc/auto.home
and the /etc/auto.home
map contains:
joe -fstype=nfs,intr sales://home/joe kyle -fstype=nfs,intr accounting://home/kyle
then when joe logs in, the automounter will create /home/joe
and attempt
to mount the /home/joe
directory exported from server sales.
mount-point program maps
The program
map type can do all sorts of interesting things, because it can
create a directory on the fly and populate with files. (This may not be
correct.)
The program receives a key (the name of the directory the user requested with
the cd
command and a set of variables in the environment:
AUTOFS_UID= AUTOFS_USER= AUTOFS_GID= AUTOFS_GROUP= AUTOFS_HOME= AUTOFS_SHOST=
The program starts in the directory specified by the managed mount point. It’s expected to return an entry; that is, a line similar to ones in a map file:
-fstype=bind :/path/to/directory
Note that the backing store for the automounted directory is not deleted when the mount point expires or autofs shuts down, so they will accumulate unless you take steps to remove them manually.
My setup for accessing penguin:/var/local
In /etc/auto.master.d/mnt.autofs:
/mnt /etc/auto.mnt
In /etc/auto.mnt:
# Automounter map for /mnt penguin -fstype=nfs,intr penguin://var/local cd -fstype=iso9660,ro :/dev/cdrom