How to Use autofs for Dynamic Mounting on Linux Servers
This guide explains why static entries in /etc/fstab can waste resources, introduces the autofs daemon for on‑demand mounting, and walks through installing autofs, configuring master and sub‑map files, enabling the service, and verifying automatic CD mounting on a Linux server.
Static mount entries in /etc/fstab cause every remote share to be mounted at boot, which can waste network bandwidth and server resources when many mounts are unused.
The autofs daemon solves this by mounting a filesystem only when a user accesses its path, acting as an on‑demand automounter.
Install autofs on a RHEL/CentOS system:
# yum install autofs
Loaded plugins: langpacks, product-id, subscription-manager
... (installation output) ...
Complete!Configure the master map /etc/auto.master using the format mount‑point sub‑map‑file . Sub‑map files must end with .misc and contain detailed mount definitions.
# vim /etc/auto.master
# Sample auto.master file
# key [ -mount-options ] location
/media /etc/iso.misc
/misc /etc/auto.misc
+dir:/etc/auto.master.d
+auto.masterCreate a sub‑map file for the CD device, e.g., /etc/iso.misc:
iso -fstype=iso9660,ro,nosuid,nodev :/dev/cdromStart and enable autofs so it runs at boot:
# systemctl start autofs
# systemctl enable autofsAfter configuration, the CD is not mounted initially, but navigating to /media/iso triggers autofs to mount it automatically, allowing you to list its contents. The df -h output shows the CD device appearing under /media/iso only after access.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 18G 3.0G 15G 17% /
... (other filesystems) ...
/dev/cdrom 3.5G 3.5G 0 100% /media/isoThis demonstrates how autofs reduces unnecessary resource usage while providing seamless access to remote or removable filesystems.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
