14.2 Configure autofs

Key Takeaways

  • autofs mounts file systems on demand when a path under a managed base is accessed, and can unmount them after idle timeout—ideal for NFS home or shared trees.
  • Master map /etc/auto.master (or auto.master.d drop-ins) points mount bases to map files; indirect maps list keys relative to that base.
  • Install and enable the service with systemctl enable --now autofs (or enable + start); reload maps after edits with systemctl reload autofs.
  • Typical indirect NFS line: key -options server:/export/key or wildcard * -options server:/export/& for home directories.
  • Exam success is accessing the autofs path so the NFS share appears automatically and configuration survives reboot via enabled autofs—not only a static mount -t nfs.
Last updated: August 2026

14.2 Configure autofs

Quick Answer: Install autofs, define a master map entry and an indirect map for your NFS keys, then systemctl enable --now autofs. Access /base/key to trigger the mount; confirm with findmnt. On EX200, autofs is the tool for on-demand mounts that should not sit in fstab as always-mounted NFS.

Official skill and why it matters

Under Create and configure file systems, Red Hat expects you to configure autofs. Lab language often looks like:

  • “Configure autofs to mount server:/exports/homes/username at /homes/username when accessed.”
  • “Users’ home directories under /home should automount from NFS using autofs.”
  • “Set up an indirect autofs map so /mnt/projects/alpha mounts nfs.example.com:/exports/projects/alpha.”

autofs (the automount program managed by the autofs systemd unit) watches configured directories and mounts only when something looks up a key under that directory. After idle time, it can unmount again. That differs from a permanent fstab NFS mount, which is intended to stay mounted after boot/mount -a.

autofs vs static NFS mount

ApproachWhen it mountsTypical use
mount -t nfs / fstab nfsBoot or manual mount -aAlways-needed shares
autofsOn first access to the pathHomes, many project shares, optional branches

If the task says autofs, automount, or “when the user accesses,” do not only add fstab. If the task says “mount at boot permanently,” fstab NFS (14.1) is usually enough. Read the verb carefully.

Package and service

sudo dnf install -y autofs
rpm -q autofs
systemctl status autofs
sudo systemctl enable --now autofs
# equivalent stepwise:
# sudo systemctl enable autofs
# sudo systemctl start autofs

systemctl enable autofs (or enable --now) makes the service start at boot so maps survive reboot—the EX200 persistence rule applies to the service, not to keeping every NFS share permanently mounted.

After changing maps:

sudo systemctl reload autofs
# if reload is insufficient in a broken state:
sudo systemctl restart autofs

Verify the unit:

systemctl is-enabled autofs
systemctl is-active autofs

Master map: /etc/auto.master and drop-ins

The master map lists mount points (bases) and which map defines keys under them.

Classic file: /etc/auto.master

# mount-point     map-file            options
/homes            /etc/auto.homes
/mnt/projects     /etc/auto.projects  --timeout=60

Modern RHEL also uses drop-in directories such as /etc/auto.master.d/ with files ending in .autofs:

# Example: /etc/auto.master.d/homes.autofs
/homes  /etc/auto.homes

Either style works if the master configuration ultimately includes your base and map path. Prefer matching existing host style: if the system already uses auto.master.d, add a drop-in there; otherwise a clear line in /etc/auto.master is fine for exams.

Master map fields (mental model)

FieldRole
Mount pointParent directory autofs manages (e.g. /homes)
MapFile, program, or LDAP map defining keys (exam: almost always a file)
OptionsOptional timeouts and global options for that map

Indirect mounts (the EX200 workhorse): keys are subdirectories of the mount point. Accessing /homes/alice looks up key alice in the map for /homes.

Direct maps use absolute key paths in a special /- master entry—less common on RHCSA labs. Master indirect unless the task explicitly demands direct maps.

Indirect map files

Example /etc/auto.homes:

# key     [mount-options]  location
alice     -fstype=nfs,rw   server1.example.com:/exports/homes/alice
bob       -fstype=nfs,rw   server1.example.com:/exports/homes/bob

Access:

ls /homes/alice
# automount triggers → NFS mounts server1:/exports/homes/alice on /homes/alice
findmnt /homes/alice

Wildcard maps for home directories

When every user key maps to the same pattern on the server, use * and &:

# /etc/auto.homes
*    -fstype=nfs,rw   server1.example.com:/exports/homes/&
TokenMeaning
*Match any key (alice, bob, …)
&Substitute the key name into the location

So access to /homes/carol mounts server1.example.com:/exports/homes/carol.

This pattern is extremely common for “automount NFS homes” tasks.

Options placement

Options can sit:

  1. In the map line after the key: -fstype=nfs,rw,soft
  2. In the master map for the whole map: --timeout=60
  3. Sometimes in /etc/autofs.conf for global defaults (timeouts, logging)—edit maps first on timed exams unless the task points at conf.
# Map line with options
projects  -fstype=nfs,rw,soft  storage.example.com:/exports/projects

For NFS, fstype=nfs (or nfs4) should match what works with manual mount -t nfs on that server.

Permissions and the base directory

  • The master mount point (e.g. /homes) is managed by automount. Do not permanently mount something else on the same path.
  • You generally do not pre-create every key subdirectory; autofs creates the mountpoint when the key is accessed.
  • Local files already sitting under /homes can hide or conflict with automount keys—keep the base clean for automounted content.

End-to-end exam workflows

Workflow A — Indirect map for one project share

Task: When /mnt/data/report is accessed, mount nfs.lab.example.com:/exports/report using autofs; enable for boot.

sudo dnf install -y autofs

# Master (or auto.master.d drop-in):
# /mnt/data   /etc/auto.data

echo '/mnt/data  /etc/auto.data' | sudo tee -a /etc/auto.master
# Safer on some systems: create /etc/auto.master.d/data.autofs with that line instead

cat <<'EOF' | sudo tee /etc/auto.data
report  -fstype=nfs,rw  nfs.lab.example.com:/exports/report
EOF

sudo systemctl enable --now autofs
sudo systemctl reload autofs

ls /mnt/data/report
findmnt /mnt/data/report

Workflow B — NFS homes with wildcard

Task: Automount each user’s directory from utility:/homes/& under /remote/homes.

sudo dnf install -y autofs

# /etc/auto.master.d/remotehomes.autofs
echo '/remote/homes  /etc/auto.remotehomes' | sudo tee /etc/auto.master.d/remotehomes.autofs

cat <<'EOF' | sudo tee /etc/auto.remotehomes
*  -fstype=nfs,rw  utility.example.com:/homes/&
EOF

sudo systemctl enable --now autofs
sudo systemctl reload autofs
ls /remote/homes/student1
findmnt /remote/homes/student1

(Replace host/export with the task’s values; ensure nfs-utils works for NFS client mounts as in 14.1.)

Workflow C — Verify service without mounting everything

systemctl status autofs
# Trigger one key only:
ls /homes/alice
mount | grep -E 'nfs|autofs'

Idle unmount may remove the NFS mount after the configured timeout—re-access the path if findmnt is empty later; that still proves autofs works.

Workflow D — Broken map fix

# Access fails or mounts wrong export
sudo cat /etc/auto.master /etc/auto.master.d/* 2>/dev/null
sudo cat /etc/auto.homes
sudo systemctl restart autofs
journalctl -u autofs -e --no-pager
# Fix typos in key, server, or export; reload/restart; test again

Map syntax traps

  1. Master points to wrong map path/etc/auto.homes vs where you wrote the file.
  2. Key name mismatch — map key alice but user accesses /homes/Alice (case matters).
  3. Forgetting * / & pairing* without & will not expand the export path correctly for each user.
  4. Using fstab and autofs on the same mountpoint — conflicts; pick one per task.
  5. Service not enabled — works until reboot, then automount dies.
  6. NFS server path wrong — same as 14.1; test with manual mount -t nfs once if allowed, then put the working location into the map.
  7. Spaces and comment errors — keep map lines clean; # starts comments.
  8. Mount point is a file not a directory — rare, but broken bases fail activation.

Configuration file checklist

FilePurpose
/etc/auto.masterMaster map (bases → maps)
/etc/auto.master.d/*.autofsDrop-in master fragments
/etc/auto.* custom mapsIndirect keys and NFS locations
/etc/autofs.confGlobal daemon defaults (timeouts, logging)
systemd unit autofsStart/enable/reload service

Interaction with NFS client skills

autofs still uses the NFS client stack. If manual mount -t nfs server:/export /mnt/test fails, autofs will also fail for that location. Fix network, nfs-utils, firewall on the server side, and export path first. Then encode the working server:/export into the map.

showmount -e server (14.1) still helps discover export paths for map lines when available.

Logging and timeouts

  • Default idle unmount timeouts vary by configuration (TIMEOUT in autofs.conf or master --timeout=).
  • Short timeouts can confuse testers who findmnt after waiting—re-access the path.
  • For exams, default timeouts are usually fine unless the task sets a specific timeout.
grep -E '^(TIMEOUT|MOUNT_WAIT)' /etc/autofs.conf 2>/dev/null

Common traps

  1. Only installing autofs without maps — service runs but nothing mounts.
  2. Editing maps without reload/restart — old maps remain active.
  3. Putting full absolute paths as keys in an indirect map — keys are relative (alice, not /homes/alice).
  4. Expecting mount at boot without access — autofs is on-demand; grader may ls the path to trigger.
  5. Disabling autofs after testing — leave it enabled.
  6. SELinux denials — less common for simple NFS automount; check ausearch/journalctl if mounts are denied after syntax is correct.
  7. Firewall blocking NFS — same class of failures as static NFS.
  8. Confusing master options with map options — master --timeout=60 vs map -fstype=nfs.

Relationship to other objectives

SkillWhere
Static NFS mount/umount/fstabSection 14.1
autofs master/maps/serviceThis section
Local mounts by UUIDStorage chapters
User home creationUsers and groups chapter (homes may be local or NFS via autofs)

Section checkpoint

You should install autofs, write a master map entry (auto.master or auto.master.d), create an indirect map with explicit keys or */& wildcards for NFS locations, enable and start the service with systemctl enable --now autofs, reload after edits, and verify by accessing /base/key and checking findmnt. That is the EX200 bar for configuring autofs so network file systems appear on demand and the configuration survives reboot.

Test Your Knowledge

Which pair of actions best ensures autofs starts now and again after reboot on RHEL?

A
B
C
D
Test Your Knowledge

In an indirect autofs map for base /homes, which line mounts server:/exports/homes/USERNAME when a user accesses /homes/USERNAME?

A
B
C
D
Test Your Knowledge

What is the role of /etc/auto.master (or files under /etc/auto.master.d/) in an autofs setup?

A
B
C
D
Test Your Knowledge

You edited /etc/auto.projects but accessing /mnt/projects/alpha does not mount. autofs is active. What is a sensible next step?

A
B
C
D