/etc/fstabis that, regardless of how infrequently a user accesses the NFS mounted file system, the system must dedicate resources to keep the mounted file system in place. This is not a problem with one or two mounts, but when the system is maintaining mounts to many systems at one time, overall system performance can be affected. An alternative to
/etc/fstabis to use the kernel-based
automountutility. An automounter consists of two components:
- a kernel module that implements a file system, and
- a user-space daemon that performs all of the other functions.
automountutility can mount and unmount NFS file systems automatically (on-demand mounting), therefore saving system resources. It can be used to mount other file systems including AFS, SMBFS, CIFS, and local file systems.
/etc/auto.master(master map) as its default primary configuration file. This can be changed to use another supported network source and name using the
/etc/sysconfig/autofs) in conjunction with the Name Service Switch (NSS) mechanism. An instance of the
autofsversion 4 daemon was run for each mount point configured in the master map and so it could be run manually from the command line for any given mount point. This is not possible with
autofsversion 5, because it uses a single daemon to manage all configured mount points; as such, all automounts must be configured in the master map. This is in line with the usual requirements of other industry standard automounters. Mount point, hostname, exported directory, and options can all be specified in a set of files (or other supported network sources) rather than configuring them manually for each host.
8.4.1. Improvements in autofs Version 5 over Version 4
autofsversion 5 features the following enhancements over version 4:
- Direct map support
- Direct maps in
autofsprovide a mechanism to automatically mount file systems at arbitrary points in the file system hierarchy. A direct map is denoted by a mount point of
/-in the master map. Entries in a direct map contain an absolute path name as a key (instead of the relative path names used in indirect maps).
- Lazy mount and unmount support
- Multi-mount map entries describe a hierarchy of mount points under a single key. A good example of this is the
-hostsmap, commonly used for automounting all exports from a host under
/net/hostas a multi-mount map entry. When using the
/net/hostwill mount autofs trigger mounts for each export from host. These will then mount and expire them as they are accessed. This can greatly reduce the number of active mounts needed when accessing a server with a large number of exports.
- Enhanced LDAP support
autofsconfiguration file (
/etc/sysconfig/autofs) provides a mechanism to specify the
autofsschema that a site implements, thus precluding the need to determine this via trial and error in the application itself. In addition, authenticated binds to the LDAP server are now supported, using most mechanisms supported by the common LDAP server implementations. A new configuration file has been added for this support:
/etc/autofs_ldap_auth.conf. The default configuration file is self-documenting, and uses an XML format.
- Proper use of the Name Service Switch (
- The Name Service Switch configuration file exists to provide a means of determining from where specific configuration data comes. The reason for this configuration is to allow administrators the flexibility of using the back-end database of choice, while maintaining a uniform software interface to access the data. While the version 4 automounter is becoming increasingly better at handling the NSS configuration, it is still not complete. Autofs version 5, on the other hand, is a complete implementation.Refer to
man nsswitch.conffor more information on the supported syntax of this file. Not all NSS databases are valid map sources and the parser will reject ones that are invalid. Valid sources are files,
- Multiple master map entries per autofs mount point
- One thing that is frequently used but not yet mentioned is the handling of multiple master map entries for the direct mount point
/-. The map keys for each entry are merged and behave as one map.
Example 8.2. Multiple Master Map Entries per autofs Mount PointAn example is seen in the connectathon test maps for the direct mounts below:
/- /tmp/auto_dcthon /- /tmp/auto_test3_direct /- /tmp/auto_test4_direct
8.4.2. Configuring autofs
/etc/auto.master, also referred to as the master map which may be changed as described in the Section 8.4.1, “Improvements in autofs Version 5 over Version 4”. 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
/home, for example.
- 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. The syntax for a map entry is described below.
- If supplied, these will apply to all entries in the given map provided they don't themselves have options specified. This behavior is different from
autofsversion 4 where options were cumulative. This has been changed to implement mixed environment compatibility.
/etc/auto.masterfile (displayed with
mount-point [options] location
- This refers to the
autofsmount point. This can be a single directory name for an indirect mount or the full path of the mount point for direct mounts. Each direct and indirect map entry key (
mount-pointabove) may be followed by a space separated list of offset directories (sub directory names each beginning with a "/") making them what is known as a multi-mount entry.
- Whenever supplied, these are the mount options for the map entries that do not specify their own options.
- This refers to the file system location such as a local file system path (preceded with the Sun map format escape character ":" for map names beginning with "/"), an NFS file system or other valid file system location.
payroll -fstype=nfs personnel:/dev/hda3 sales -fstype=ext3 :/dev/hda4
autofsmount point (
payrollfrom the server called
personnel). The second column indicates the options for the
autofsmount while the third column indicates the source of the mount. Following the above configuration, the autofs mount points will be
-fstype=option is often omitted and is generally not needed for correct operation.
- If the automount service has stopped:
systemctl start autofs
- If the service is running:
systemctl restart autofs
autofsunmounted directory such as
/home/payroll/2006/July.sxc, the automount daemon automatically mounts the directory. If a timeout is specified, the directory will automatically be unmounted if the directory is not accessed for the timeout period.
systemctl status autofs
8.4.3. Overriding or Augmenting Site Configuration Files
- Automounter maps are stored in NIS and the
/etc/nsswitch.conffile has the following directive:
automount: files nis
auto.masterfile contains the following
- The NIS
auto.mastermap file contains the following:
- The NIS
auto.homemap contains the following:
beth fileserver.example.com:/export/home/beth joe fileserver.example.com:/export/home/joe * fileserver.example.com:/export/home/&
- The file map
/etc/auto.homedoes not exist.
auto.homeand mount home directories from a different server. In this case, the client will need to use the following
/home /etc/auto.home +auto.master
/etc/auto.homemap contains the entry:
/homewill contain the contents of
/etc/auto.homeinstead of the NIS
auto.homemap with just a few entries, create an
/etc/auto.homefile map, and in it put the new entries. At the end, include the NIS
auto.homemap. Then the
/etc/auto.homefile map will look similar to:
mydir someserver:/export/mydir +auto.home
auto.homemap listed above,
ls /homewould now output:
beth joe mydir
autofsdoes not include the contents of a file map of the same name as the one it is reading. As such,
autofsmoves on to the next map source in the
8.4.4. Using LDAP to Store Automounter Maps
openldappackage should be installed automatically as a dependency of the
automounter. To configure LDAP access, modify
/etc/openldap/ldap.conf. Ensure that BASE, URI, and schema are set appropriately for your site.
rfc2307bis. To use this schema it is necessary to set it in the
/etc/sysconfig/autofs) by removing the comment characters from the schema definition. For example:
Example 8.4. Setting autofs Configuration
DEFAULT_MAP_OBJECT_CLASS="automountMap" DEFAULT_ENTRY_OBJECT_CLASS="automount" DEFAULT_MAP_ATTRIBUTE="automountMapName" DEFAULT_ENTRY_ATTRIBUTE="automountKey" DEFAULT_VALUE_ATTRIBUTE="automountInformation"
cnattribute in the
LDIFof a sample configuration is described below:
Example 8.5. LDF Configuration
# extended LDIF # # LDAPv3 # base <> with scope subtree # filter: (&(objectclass=automountMap)(automountMapName=auto.master)) # requesting: ALL # # auto.master, example.com dn: automountMapName=auto.master,dc=example,dc=com objectClass: top objectClass: automountMap automountMapName: auto.master # extended LDIF # # LDAPv3 # base <automountMapName=auto.master,dc=example,dc=com> with scope subtree # filter: (objectclass=automount) # requesting: ALL # # /home, auto.master, example.com dn: automountMapName=auto.master,dc=example,dc=com objectClass: automount cn: /home automountKey: /home automountInformation: auto.home # extended LDIF # # LDAPv3 # base <> with scope subtree # filter: (&(objectclass=automountMap)(automountMapName=auto.home)) # requesting: ALL # # auto.home, example.com dn: automountMapName=auto.home,dc=example,dc=com objectClass: automountMap automountMapName: auto.home # extended LDIF # # LDAPv3 # base <automountMapName=auto.home,dc=example,dc=com> with scope subtree # filter: (objectclass=automount) # requesting: ALL # # foo, auto.home, example.com dn: automountKey=foo,automountMapName=auto.home,dc=example,dc=com objectClass: automount automountKey: foo automountInformation: filer.example.com:/export/foo # /, auto.home, example.com dn: automountKey=/,automountMapName=auto.home,dc=example,dc=com objectClass: automount automountKey: / automountInformation: filer.example.com:/export/&