[Next] [Previous] [Up] [Top] [Contents]

20.4 SunOS 5.X

20.4.5 The Automount File System, autofs

Autofs mounts file systems when they are accessed and unmounts them after a specified period of inactivity. It uses the automount daemon, /usr/lib/autofs/automountd, to control the mounting of file systems. This daemon is started at run-level 2 by the /etc/init.d/autofs script which also mounts the file systems with the /usr/sbin/automount command.

The automount system doesn't use /etc/vfstab to specify file systems. It uses the maps specified in the /etc/auto_master file and in the NIS(+) system. (This file is known as auto.master for NIS.) The auto_master file has entries of the form:

#mount-point map-name [ mount-options ]
/net -hosts -nosuid
/home auto_home

In this file +auto_master refers to an NIS(+) master map. If one exists insert those entries as if they were part of this file. The remaining entries specify the directory to automount the file and the automount map associated with it. The -hosts map entry specifies all the NFS exported file systems in the NIS(+) hosts database. These will be mounted on /net, e.g. the file systems for a host, tardis, will be mounted on /net/tardis. For the last entry in auto_master there is a corresponding /etc/auto_home file with contents:


indicating that the auto_home NIS(+) map should be used. (This file is known as auto.home for NIS.) When the location of this file is not specified by the complete path name it is follows the convention determined by the automount entry in /etc/nsswitch.conf, e.g.:

automount: files nis

which specifies that the files in /etc should be checked first, followed by the NIS maps. The auto_home table maps login names with directories, and is managed through the NIS(+) system.

The automount maps can be direct or indirect. The direct maps specifies a mount point on the client for a specific directory on the server. An indirect map refers to a table of automount points. The indirect map is the more common way of using the automounter.

In a direct map you can specify more than one server from which to access read-only file systems, e.g.:

/usr/man -ro server1:/usr/man server2:/usr/man server3:/usr/man

The system will mount the nearest available server, with those on the same subnet being given preference.

You can use certain variables in these maps by prefacing a dollar sign to the variable name. The variable names recognized by the automounter are:

Variable Name Variable Meaning Example

ARCH hardware architecture sun4c

CPU processor type sparc

HOST hostname nyssa

OSNAME operating system name SunOS

OSREL operating system release number 5.5

OSVERS operating system version FCS1.0

When you make an addition or deletion to a direct map you need to run the automount command to have the change take effect. Modifications to existing entries don't require you to do this.

To modify the master NIS+ maps use the nistbladm command then run the automount command to have the changes take effect. We'll look at the nistbladm command in the chapter on NIS+ later in the course.

You can access non-NFS file systems through the automounter, including removable media and cachefs file systems. For these you need to specify the file system type and the device file or cache to use. To mount a cachefs file system put an entry similar to the following in master map:

/home auto_home -fstype=cachefs, cache=/local/cache

You can not automount a file system on top of another automounted file system.

By default when you boot your system it will try to automount the home directories known to the NIS(+) server. If you don't want to run the automounter move the file, /etc/rc2.d/S74autofs, to a name not beginning with "S", e.g. old.S74autofs.

Unix System Administration - 8 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]