Linux / UNIX OS service : autofs

Service Name

autofs

Description

This executes auto-mount daemon for filesystem mounting. The “auto-mount” daemon “mounts a filesystem when a client sends a request to this daemon” and “unmount it when there’s no request for a long time”. There are two types of automounters in Linux, autofs and AMD. AMD is implemented in user space and not a part of kernel. However, autofs is a newer system assisted by the kernel and it requires kernel lever support.

As said before, autofs is implemented in kernel-space, so in order to use autofs the kernel must have support compiled in. All versions of the kernel starting from 2.2.xx supports autofs. The following command can be used to check if it is compiled in kernel.

# cat /proc/filesystems | grep autofs
nodev   autofs
#

The autofs use “maps” to define the filesystem to mount. Different automounters maps are not compatible with each other, eg: amd maps are not compatible with autofs. When autofs starts, it will consult a configuration file /etc/auto.master to find mount points on the system. For each of those mount points a automount process is started with the appropriate parameters. After the auto.master configuration file is processed the autofs will check for an NIS map with the same name.

The autofs should not be used in the system which needs higher performance because dynamic mounting brings some overhead.

The RPM package containing this service are:

autofs
Nature

Service Control

This service is handled by init.d script /etc/init.d/autofs. Its usage is as follows:

# /sbin/service autofs
Usage: /etc/init.d/autofs {start|stop|restart|reload|condrestart|status}

Start the service as follows:

# /sbin/service autofs start
Starting automount: No Mountpoints Defined                 [  OK  ]

Stop the service as follows:

# /sbin/service autofs stop
Stopping automount:                                        [  OK  ]

Check if the service is started or stopped:

# /sbin/service autofs status
Configured Mount Points:
------------------------

Active Mount Points:
--------------------

#

Restart will kill running daemons and start the service again.

# service autofs restart
Stopping automount:                                        [  OK  ]
Starting automount: No Mountpoints Defined                 [  OK  ]

If the service is started, then restart it; otherwise do nothing.

# service autofs condrestart

Reload command will check auto.master map against running daemons. It will kill those daemons whose entries have changed and then start daemon for new or changed entries.

# service autofs reload

Query runlevel information for the service to check the service boot options after reboot:

# chkconfig --list autofs
autofs      0:off   1:off   2:on    3:on    4:on    5:on    6:off

Configuration

The autofs automounter uses a configuration file /etc/auto.master to define mount point maps. When starting up, it will check this file and start automount daemons for every entries in this file. For example, the default file comments out all the entries.

#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#/misc  /etc/auto.misc --timeout=60
#/misc  /etc/auto.misc
#/net   /etc/auto.net

Along with /etc/auto.master file, autofs also will check NIS map. If such a map exists then that map will be processed in the same way as the auto.master map.The NIS map will be processed last.

As auto.master file shows, all the mount point maps are partitioned into different categories, such as misc, net etc. Each file contains some maps with detailed mount options. For example, the content of /etc/auto.misc is as follows:

#
# $Id: auto.misc,v 1.2 2003/09/29 08:22:35 raven Exp $
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

# the following entries are samples to pique your imagination
#linux          -ro,soft,intr           ftp.example.org:/pub/linux
#boot           -fstype=ext2            :/dev/hda1
#floppy         -fstype=auto            :/dev/fd0
#floppy         -fstype=ext2            :/dev/fd0
#e2floppy       -fstype=ext2            :/dev/fd0
#jaz            -fstype=ext2            :/dev/sdc1
#removable      -fstype=ext2            :/dev/hdd

Configuration Files:

/etc/auto.master               Master map file for automounter
/etc/auto.misc                   Mount point map definitions
Related Post