Simple autofs direct map example
The autofs program is designed to automatically mount directories only when they are accessed, and to unmount them after a period of inactivity. This behaviour helps conserve bandwidth and improves overall performance, especially compared to static mounts defined in fstab. By using this approach for NFS or Samba shares, the system avoids keeping remote resources permanently active while still providing seamless access when needed.
The steps below illustrate how to set up automatic access to a remote NFS directory, from creating the local mount point to configuring and activating the automounter, and finally verifying that the remote storage is correctly reachable.
Create the auto direct
Create a directory on the local server:
# mkdir /mnt/backups |
Open the /etc/auto.direct file:
# vim /etc/auto.direct |
Configure the automount in the /etc/auto.direct file by adding the following line:
/mnt/backups -fstype=nfs,rw,tcp,sec=sys distant-storage.org:/backups/year2025 |
Then launch the automount command:
# automount |
Now the /backups/year2025 distant directory is reachable from the local /mnt/backups.
Check the file system:
# df -h |
devtmpfs 4.0M 0 4.0M 0% /dev |
Documentation
Internet