
This guide uses the example NFS server
10.0.2.15 exporting under /srv/nfs/. Replace the IP and export paths to match your environment. These examples assume a RHEL-like system (CentOS, Fedora, Rocky, Alma).What you’ll configure
- Install and enable the
autofsservice. - Create a master map file (
/etc/auto.master.d/master.autofs) that references:- a direct map (
/etc/auto.direct), and - an indirect map (
/etc/auto.indirect).
- a direct map (
- Test that NFS exports are mounted on-demand when accessed.
Installation and enabling the autofs service
Install autofs:--now to enable and start in one step):
Configuring the autofs master file and maps
autofs uses a master map that points to one or more map files. Modern RHEL-like distributions allow dropping files with the.autofs suffix into /etc/auto.master.d/. Create a file /etc/auto.master.d/master.autofs that tells autofs where to find the direct and indirect maps.
Create /etc/auto.master.d/master.autofs:
/-(direct map) means each key in/etc/auto.directis a full absolute path to be mounted./indirect(indirect map) means subdirectories under/indirectare created on-demand according to keys found in/etc/auto.indirect.
Direct map: absolute mount points
Create/etc/auto.direct. Direct maps use absolute mount points. Example: mount the export 10.0.2.15:/srv/nfs/share at /auto-direct:
- The left column is the absolute mount point.
- The middle field lists mount options (
-rw,sync). - The right side is the NFS server export.
Indirect map: keyed subdirectories under a parent
Create/etc/auto.indirect. Indirect maps use keys that become subdirectories under the parent (/indirect in the master file). Using a wildcard allows matching multiple keys:
*matches any subdirectory name under/indirect.&expands to the matched key, so accessing/indirect/centralmounts10.0.2.15:/srv/nfs/share/autofs-indirect/central.
Quick reference: map files
Testing the automounts
After restarting autofs, autofs creates the mount-point directories even before the NFS mounts occur. Verify the directories exist:/indirect is mounted individually and on-demand when first accessed. For example, accessing /indirect/east will mount 10.0.2.15:/srv/nfs/share/autofs-indirect/east.
This on-demand mount behavior avoids slow or stalled boots caused by unreachable network shares.
If the NFS server is unreachable, autofs will not block boot; however, processes that try to access a missing mount point will hang until the mount times out or the server becomes available. Ensure NFS server accessibility, firewall rules, and SELinux contexts are correct for your environment.
Troubleshooting tips
- Confirm the NFS server and exported paths are reachable:
showmount -e 10.0.2.15. - Check
journalctl -u autofsfor autofs-specific logs and errors. - If mounts fail, verify NFS client packages (
nfs-utils) are installed and that the firewall allows NFS traffic. - For SELinux-denied mounts, inspect
ausearchoraudit.logand apply required boolean / context fixes.
Summary
You have configured autofs to manage both direct and indirect NFS automounts:- Installed and enabled the
autofsservice. - Created a master map file (
/etc/auto.master.d/master.autofs) referencing a direct map (/etc/auto.direct) and an indirect map (/etc/auto.indirect). - Used direct maps for absolute mount points and indirect maps for keyed on-demand subdirectories with wildcard matching and
&substitution. - Verified that NFS exports are mounted only when accessed, improving boot reliability and reducing dependency on network availability.

Links and references
- autofs manual: https://linux.die.net/man/5/auto.master
- NFS basics: https://nfs.sourceforge.net/
- RHEL autofs documentation: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/ (search for “autofs”)