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
tmpfs 3.1G 289M 2.8G 10% /run
/dev/mapper/rootvg-rootvol 196G 27G 169G 14% /
/dev/sda1 448M 277M 172M 62% /boot
distant-storage.org:/backups/year2025 115T 41T 74T 36% /mnt/backups

Documentation

Internet

🡅 Partager