Configuring the Automounter
The automounter mounts file systems when they're accessed, rather than maintaining connections for those mounts all the time. When a file system becomes inactive for a certain period, the automounter unmounts it. Using automounting frees up system resources and improves system performance.
The automounter consists of two components: the
autofs
kernel module and the
automount
user-space daemon. It also references
entries in /etc/auto.master
, which is the
automounter configuration file.
About the Automounter Configuration File
In the /etc/auto.master
configuration file,
each map entry specifies a mount point and a map file that
contains definitions of the remote file systems that can be
mounted, for example:
/- /etc/auto.direct /misc /etc/auto.misc /net -hosts
The previous example shows the following types of map entries:
-
/-
: direct map entry. Direct map entries always specify/-
as the mount point. -
/misc
: indirect map entry. -
/net
: host map entry. Host maps always specify the keyword-hosts
instead of a map file.
A direct map contains definitions of directories that are
automounted at the specified absolute path. In the example, the
auto.direct
map file might contain an entry
similar to the following:
/usr/man -fstype=nfs,ro,soft host01:/usr/man
This entry is a directive to do the following:
-
Mount the file system
/usr/man
that's exported byhost01
by specifying thero
andsoft
options. -
Create the
/usr/man
mount point if it doesn't already exist. If the mount point exists , the mounted file system hides any existing files that it contains.
Because the default file system type is NFS, the previous example can be shortened to read as follows:
/usr/man -ro,soft host01:/usr/man
An indirect map contains definitions of directories or keys that are automounted
relative to the mount point (/misc
) that's specified in the
/etc/auto.master
file. For example, the /etc/auto.misc
map
file might contain entries similar to the following:
xyz -ro,soft host01:/xyz cd -fstype=iso9600,ro,nosuid,nodev :/dev/cdrom abc -fstype=ext3 :/dev/hda1 fenetres -fstype=cifs,credentials=credfile ://fenetres/c
Note that the /misc
directory must already exist; however, the automounter
creates a mount point for the keys xyz
, cd
, and so on, if
they don't already exist, and then removes them when it unmounts the file system.
For example, using the ls /misc/xyz command
causes the automounter to the mount the /xyz
directory, exported by host01
as
/misc/xyz
.
The cd
and abc
entries
mount the following local file systems: an ISO image from the
CD-ROM drive on /misc/cd
and an ext3 file
system from /dev/hda1
on
/misc/abc
. The fenetres
entry mounts a Samba share as /misc/fenetres
.
If a host map entry exists, and a command references an NFS server that's relative to the
mount point (/net
) by name, the automounter mounts all the directories that
the server exports within a subdirectory of the mount point named for the server. For example,
the cd /net/host03 command causes the automounter to mount all exports
from host03
under the /net/host03
directory. By default, the
automounter uses the nosuid,nodev,intr
mount options unless you override the
options in the host map entry, as follows:
/net -hosts -suid,dev,nointr
Note:
The name of the NFS server must be resolvable to an IP address
in DNS or the /etc/hosts
file.
For more information about NFS administration, see the Using NFS in Oracle Linux chapter in Oracle Linux 8: Managing Shared File Systems
Oracle Linux 9: Managing Shared File
Systems. See also the
hosts.master(5)
and auto.master(5)
manual pages.
Installing and Enabling the Automounter
-
Install the
autofs
package and any other packages that are required to support remote file systems:sudo dnf install autofs
-
Edit the
/etc/auto.master
configuration file to define map entries that are appropriate to the file systems.See About the Automounter Configuration File for reference.
-
Start the
autofs
service, and configure the service to start following a system reboot:sudo systemctl start autofs sudo systemctl enable autofs
You can configure various settings for autofs
in the /etc/sysconfig/autofs
file, including
the idle timeout value after which a file system is
automatically unmounted.
If you change the /etc/auto.master
or
/etc/sysconfig/autofs
file, restart the autofs
service to
reread these files:
sudo systemctl restart autofs
For more information, see the automount(8)
and autofs(5)
manual pages.