Automount
File systems that are used frequently
can be NFS mounted as described in the preceding chapters. However, not all remote file systems need to
be mounted all the time. Some remote
resources may be rarely used and required only occasionally, and it is possible
to set up a client to mount those resources only when demanded. This is called automounting.
Automounting requires no
server setup beyond that required to share any remote resource. On the client side there are a set of files
which must be configured and read, and a daemon, automountd, which is started
by the Service Management Facility using the script /lib/svc/method/svc-autofs
when the system transitions to the multi-user milestone. It can be stopped,
started or refreshed using the FMRI svc:/system/filesystem/autofs.
# svcadm refresh autofs
Client setup - automount maps
Automount maps are files
which define the mount points and resources to mount, much as /etc/vfstab
does. The master file, /etc/auto_master,
is supplied by default with the operating system, as is the indirect map
/etc/auto_home. All others must be
created by the administrator. There are
three kinds of automount maps.
Master Map /etc/auto_master
There is one master map, and
it is always called /etc/auto_master. It
is the first map read by automountd, and it contains five kinds of entries
which define resources to mount, or which refer to other files that contain
resources to mount.
+auto_master This entry directs the automount daemon to look in a
/net -hosts
-options to mount such as rw, nosuid, nobrowse
This entry means that shared
resources on any system listed in /etc/hosts will be automounted on /net/hostname
/home auto_home -(options to mount)
A file named /etc/auto_home
exists and contains a list of mount points relative to /home and resources to
mount on those mount points.
/xfn -xfn
A file named /etc/xfn exists
and contains a list of mount points relative to /xfn, and resources to mount on
those mount points. Xfn is part of a name service called Federated Naming
Services which is not part of Unix.
/- auto_direct -options to mount
A file named /etc/auto_direct
exists and contains a list of mount points, options and resources to mount on
those mount points.
Indirect maps
Indirect maps mount resources
on directories relative to the directory given in the master map. They are used when multiple resources are
mounted below a single mount point. Many user home directories may be mounted
below the directory /home, so home directories are good candidates for
automounting via indirect maps. Any
resource may be mounted using either a direct or indirect map, however. The use
of separate direct and indirect maps is meant only to simplify and organize
automounting.
Indirect maps are indicated
in the master map, /etc/auto_master, by an entry of the form
/base_directory_for_mounts indirect_map_name -options
Each indirect map contains
entries of the form:
/mount_point_under_base_directory -options
hostname:/path/to/resource
The automounter will mount
the resource listed on the mount point given, under the base directory.
Example
of indirect map:
/flowers auto_garden -ro
Entry
in the file /etc/auto_garden
lilacs -nosuid botany:/listing/lilacs
roses -nosuid gardener:/book/roses
violets purple:/flowers/violets
In
this case the directory /listing/lilacs on the server botany will be mounted on
/flowers/lilacs, read only, with setuid disabled. Notice that this has the same
effect as the entry for lilacs in the direct map, below. The directory /book/roses on the server
gardener will be mounted on /flowers/roses.
The directory /flowers/violets on the server purple will be mounted on
/flowers/violets, read only, with setuid enabled.
The indirect map auto_home,
which mounts on /home, may also have a special entry:
* hostname,(hostname1,hostname2..):/export/home/&
This entry matches any login
to the * and the &, so that if user1 logs in, the directory
/export/home/user1 will be mounted on /home/user1. Only one such special entry
is allowed per auto_home file, however, multiple servers may be searched in the
single line.
* hostname,hostname1,hostname2:/export/home/&
Individual user accounts may also be added to
the file in addition to this entry.
Direct map
Direct
maps are used for mounting single resources, such as man pages. A single direct
map can contain all the resources used on the system, so it is quite common for
there to be only one direct map, named /etc/auto_direct.
A direct map is indicated in
the file auto_master by an entry which begins with /- followed by the name of the map in /etc, such
as auto_direct.
A direct map lists 3 items
per line: 1) absolute paths to mount
points, 2) mount options and 3) resources to mount. The resources to mount take the same format
as they do for nfs mounted remote files; hostname: /path/to/shared/resource.
As in nfs mounted files, entries may also take the form hostname1,hostname2,hostname3:/path/to/share/resource,
in which case the first host contacted will share the resource with the
client.
Format of entry:
mountpoint -options hostname:/path/to/resource
The automounter will mount
the resource listed on the mount point listed.
Example:
Entry in /etc/auto_master
/- auto_direct -nosuid
Entry in /etc/auto_direct
/usr/share/man -ro manserver:/usr/share/man
/flowers/lilacs -ro botany:/listing/lilacs
According to these entries,
whenever a user cds to /flowers/lilacs, the resource /listing/lilacs from the
server "botany" will automatically be mounted on that directory, read
only, with setuid disabled. Man pages
will be automounted on /usr/share/man. Obviously it is possible to get the same
result with either indirect or direct maps. Usually indirect maps are used when
there are a lot of shared resources below the same directory, as there would be
with home directories. There is ordinarily only one direct map on a host,
/etc/auto_direct, which contains all the solitary resources, like man pages.
automount
Automount maps are read at
boot time automatically. If changes are
made to the master map, or any direct maps, they must be reread, using the
command:
automount -v
If
you make a change to a home directory, touch /etc/passwd:
touch /etc/passwd