Operations 7 min read

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.

Open Source Linux
Open Source Linux
Open Source Linux
How to Use autofs for Dynamic Mounting on Linux Servers

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.master

Create a sub‑map file for the CD device, e.g., /etc/iso.misc:

iso   -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

Start and enable autofs so it runs at boot:

# systemctl start autofs
# systemctl enable autofs

After 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/iso

This demonstrates how autofs reduces unnecessary resource usage while providing seamless access to remote or removable filesystems.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Linuxfstabautofsdynamic mountingon-demand filesystems
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.