Configure autofs to mount file systems on access and free resources when idle. 16.11.2025 | reading time: 3 min Autofs is a Linux daemon that mounts file systems on first access and unmounts them after inactivity, saving resources and simplifying user workflows; this page shows a concrete configuration and a quick demo so he can reproduce it on his system. Quick setup demo Follow these commands to install and enable autofs, add a direct map, and verify the mount: ```sudo apt-get update && sudo apt-get install -y autofs && sudo systemctl enable --now autofs``` then create the master entry with ```echo "/- /etc/auto.direct --timeout=60" | sudo tee -a /etc/auto.master``` and create the map with ```echo "/mnt/shared -fstype=nfs4,rw nfs-server:/export/shared" | sudo tee /etc/auto.direct``` finally restart autofs and check status with ```sudo systemctl restart autofs && sudo systemctl status autofs --no-pager```. Check the result Trigger the automount by listing the mount point and inspect mounted file systems with these commands: ```ls -la /mnt/shared``` which should show files from the NFS export, and ```mount | grep /mnt/shared``` which should print an NFS line like "nfs-server:/export/shared on /mnt/shared type nfs4 (rw,...)" showing that autofs mounted it on demand. Maps, direct vs indirect, timeouts Use indirect maps to create per-directory trees under an automount point, and use direct maps to bind exact paths; entries live in files referenced from /etc/auto.master and support options such as "--timeout=60" to control unmount delay, and map types include static files, program maps and LDAP for dynamic environments. Security and mount options Specify mount options in the map entry to control credentials, read/write behavior and security, for example add "uid=1000,gid=1000,sec=krb5" for Kerberos NFS, store secrets outside world-readable maps and prefer per-service credentials or system keyrings so he avoids exposing passwords in plain text. Advanced uses and integrations Autofs pairs well with NFS for home directories, with CIFS for network shares, and with program maps to supply mounts dynamically; note that systemd also offers automount units which can be used instead of autofs when tighter systemd integration or unit-based dependencies are required. Related tools you may use Consider combining autofs with the NFS client tools for exports, cifs-utils for Samba mounts, and debugging tools such as "automount -f -v" to run the daemon in the foreground for troubleshooting and log verbosity. Next steps Try converting an existing static /etc/fstab entry to an autofs map and measure the difference in idle resource usage; experiment with program maps to mount cloud storage on demand and document the behavior so he can roll this into production policies. If he wants to deepen Linux skills, pursue hands-on study and a certification path like CompTIA Linux+ or LPIC-1; bitsandbytes.academy provides intensive exam preparation to help bridge practical knowledge and exam readiness. Join Bits & Bytes Academy First class LINUX exam preparation. setup filesystem network infrastructure storage troubleshooting