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.
14.2 Configure autofs
Quick Answer: Install
autofs, define a master map entry and an indirect map for your NFS keys, thensystemctl enable --now autofs. Access/base/keyto trigger the mount; confirm withfindmnt. 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/usernameat/homes/usernamewhen accessed.” - “Users’ home directories under
/homeshould automount from NFS using autofs.” - “Set up an indirect autofs map so
/mnt/projects/alphamountsnfs.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
| Approach | When it mounts | Typical use |
|---|---|---|
mount -t nfs / fstab nfs | Boot or manual mount -a | Always-needed shares |
| autofs | On first access to the path | Homes, 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)
| Field | Role |
|---|---|
| Mount point | Parent directory autofs manages (e.g. /homes) |
| Map | File, program, or LDAP map defining keys (exam: almost always a file) |
| Options | Optional 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/&
| Token | Meaning |
|---|---|
* | 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:
- In the map line after the key:
-fstype=nfs,rw,soft - In the master map for the whole map:
--timeout=60 - Sometimes in
/etc/autofs.conffor 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
/homescan 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
- Master points to wrong map path —
/etc/auto.homesvs where you wrote the file. - Key name mismatch — map key
alicebut user accesses/homes/Alice(case matters). - Forgetting
*/&pairing —*without&will not expand the export path correctly for each user. - Using fstab and autofs on the same mountpoint — conflicts; pick one per task.
- Service not enabled — works until reboot, then automount dies.
- NFS server path wrong — same as 14.1; test with manual
mount -t nfsonce if allowed, then put the working location into the map. - Spaces and comment errors — keep map lines clean;
#starts comments. - Mount point is a file not a directory — rare, but broken bases fail activation.
Configuration file checklist
| File | Purpose |
|---|---|
/etc/auto.master | Master map (bases → maps) |
/etc/auto.master.d/*.autofs | Drop-in master fragments |
/etc/auto.* custom maps | Indirect keys and NFS locations |
/etc/autofs.conf | Global daemon defaults (timeouts, logging) |
systemd unit autofs | Start/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 (
TIMEOUTin autofs.conf or master--timeout=). - Short timeouts can confuse testers who
findmntafter 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
- Only installing autofs without maps — service runs but nothing mounts.
- Editing maps without reload/restart — old maps remain active.
- Putting full absolute paths as keys in an indirect map — keys are relative (
alice, not/homes/alice). - Expecting mount at boot without access — autofs is on-demand; grader may
lsthe path to trigger. - Disabling autofs after testing — leave it enabled.
- SELinux denials — less common for simple NFS automount; check
ausearch/journalctlif mounts are denied after syntax is correct. - Firewall blocking NFS — same class of failures as static NFS.
- Confusing master options with map options — master
--timeout=60vs map-fstype=nfs.
Relationship to other objectives
| Skill | Where |
|---|---|
| Static NFS mount/umount/fstab | Section 14.1 |
| autofs master/maps/service | This section |
| Local mounts by UUID | Storage chapters |
| User home creation | Users 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.
Which pair of actions best ensures autofs starts now and again after reboot on RHEL?
In an indirect autofs map for base /homes, which line mounts server:/exports/homes/USERNAME when a user accesses /homes/USERNAME?
What is the role of /etc/auto.master (or files under /etc/auto.master.d/) in an autofs setup?
You edited /etc/auto.projects but accessing /mnt/projects/alpha does not mount. autofs is active. What is a sensible next step?