An autofs mount keeps an NFS export off the active mount table until a process opens the configured path. That avoids boot delays and idle network mounts on Linux clients that only need the export during certain jobs.
Autofs reads a master map, then a map file that describes the real filesystem behind each watched path. This configuration uses a direct map so /mnt/projects stays as the path users open, while autofs mounts files.example.net:/srv/nfs/projects only when that path is accessed.
A manual test with the same export should work before autofs is introduced. Replace the host, export, and mount path with site values, and keep the final checks in the flow because map syntax errors and server-side export problems often appear only when the path is first touched.
$ sudo apt update $ sudo apt install autofs nfs-common
On RHEL-family systems, install autofs and nfs-utils with sudo dnf install autofs nfs-utils.
$ sudo mkdir -p /mnt/projects
Use a path that is empty or already dedicated to this NFS export. A direct map lets autofs manage the exact path instead of creating a key under a parent directory.
$ sudo mount -t nfs4 files.example.net:/srv/nfs/projects /mnt/projects $ findmnt /mnt/projects TARGET SOURCE FSTYPE OPTIONS /mnt/projects files.example.net:/srv/nfs/projects nfs4 rw,relatime,vers=4.2 $ sudo umount /mnt/projects
$ sudo vi /etc/auto.master.d/projects.autofs
The filename must end with .autofs because packaged autofs configurations normally include only that suffix from /etc/auto.master.d.
/- /etc/auto.projects --timeout=60
The /- master-map entry tells autofs that the map file contains full mount paths. --timeout=60 lets autofs unmount idle entries after about one minute when no process is using them.
$ sudo vi /etc/auto.projects
/mnt/projects -fstype=nfs4,rw files.example.net:/srv/nfs/projects
For Kerberos-protected exports, add the matching security option, such as sec=krb5p, and confirm the client has valid Kerberos credentials before triggering the mount.
$ sudo automount -m autofs dump map information =========================== global options: none configured Mount point: /- source(s): instance type(s): file map: /etc/auto.projects /mnt/projects | -fstype=nfs4,rw files.example.net:/srv/nfs/projects
The map dump should show Mount point: /- and the full /mnt/projects key for a direct map.
$ sudo systemctl enable --now autofs.service $ sudo systemctl reload autofs.service
No output from the reload command means systemd accepted the reload request. Use sudo systemctl restart autofs.service instead when the unit does not support reload on a nonstandard distribution.
$ systemctl is-active autofs.service active
$ ls /mnt/projects README.txt reports
The first access can pause while autofs contacts the NFS server and starts the mount.
$ findmnt /mnt/projects TARGET SOURCE FSTYPE OPTIONS /mnt/projects files.example.net:/srv/nfs/projects nfs4 rw,relatime,vers=4.2
If the path stays unmounted or the command hangs, inspect sudo journalctl -u autofs.service -b and confirm the server still exports /srv/nfs/projects to the client.