sysadmin · July 6, 2026 · 14 min read

autofs on demand.
indirect and direct maps, and idle timeout.

Instead of mounting the NFS share permanently on every box, nfsadmin wants it mounted on first access and unmounted when idle. That is autofs, with both an indirect and a direct map.

// what we’re getting into
  1. The ticket
  2. Concept review. The map files, indirect versus direct.
  3. The indirect map
  4. The direct map
  5. Activate autofs and test
  6. Idle timeout
  7. Exam questions
  8. Final checklist: confirm everything works

nfsadmin liked the NFS share from yesterday but not the idea of every box in the fleet holding it mounted around the clock. What they want is on-demand: the share appears the instant someone touches the path, and quietly unmounts once it goes idle. That is autofs, and the ticket asks for it two ways, an indirect map that manages /shares/team, and a direct map that mounts /data/projects with no parent directory to manage.

Indirect and direct maps do nearly the same job and read nearly the same on paper, which is exactly why people mix them up. The difference lives in two precise spots, the auto.master line and the paths inside the map file, and getting either one wrong is the usual reason a mount silently never happens.

The ticket

bash
sudo dnf install -y autofs nfs-utils
showmount -e localhost      # confirm the NFS share is exported
ls -ld /srv/nfsshare

Concept review. The map files, indirect versus direct.

bash
man 5 auto.master
man 5 autofs

/etc/auto.master is the top file. It lists mountpoints and points each at a map file that holds the actual mounts. An indirect map manages a set of subdirectories under one parent, good when several shares live under a common directory. A direct map handles specific full paths that do not share a parent.

autofs hierarchy
/etc/auto.master        the master, lists mountpoints and their maps
  -> /etc/auto.shares   an indirect map (parent dir plus sub-mounts)
  -> /etc/auto.direct   a direct map (full path mounts)

# in auto.master:
/shares /etc/auto.shares    indirect, parent is /shares
/-      /etc/auto.direct    direct, the /- is the literal indicator

The indirect map

The map line names a subdirectory, options, and the source. The final path becomes the parent from auto.master plus the subdirectory, here /shares/team.

bash
sudo tee /etc/auto.shares << 'EOF'
team   -rw,sync   localhost:/srv/nfsshare
EOF

sudo cp /etc/auto.master /etc/auto.master.bak
echo "/shares /etc/auto.shares" | sudo tee -a /etc/auto.master

The direct map

A direct map is different in two places. The auto.master line uses the literal /- instead of a parent path, and the map file uses absolute paths on each line instead of relative subdirectories.

bash
sudo tee /etc/auto.direct << 'EOF'
/data/projects   -rw,sync   localhost:/srv/nfsshare
EOF

echo "/- /etc/auto.direct" | sudo tee -a /etc/auto.master

Activate autofs and test

Start the service, then trigger each mount just by looking into the path. autofs creates and mounts it on demand.

bash
sudo systemctl enable --now autofs
sudo systemctl reload autofs    # after editing maps

# indirect: listing the path triggers the mount
ls /shares/team
mount | grep team
cat /shares/team/welcome.txt

# direct: same idea
ls /data/projects
mount | grep projects

Idle timeout

The default idle timeout is five minutes. Access a path and it mounts, leave it alone and autofs unmounts it. You can tune the timeout in auto.master.

bash
ls /shares/team
mount | grep team          # mounted
# leave it idle past the timeout and it unmounts on its own

# set a custom timeout in auto.master:
# /shares /etc/auto.shares --timeout=60

Exam questions

Write the command first.

Q1. Install and start autofs so it is enabled at boot.

Q2. Configure an indirect map so access to /nfs/data auto-mounts server:/share read-write.

Q3. Configure a direct map to auto-mount nfsserver:/exports/projects at /projects, then verify by entering it.

Answers.

bash
# A1
sudo dnf install -y autofs
sudo systemctl enable --now autofs
# A2 (indirect)
echo 'data   -rw   server:/share' | sudo tee /etc/auto.nfs
echo '/nfs /etc/auto.nfs' | sudo tee -a /etc/auto.master
sudo systemctl reload autofs; ls /nfs/data
# A3 (direct)
echo '/projects  -rw  nfsserver:/exports/projects' | sudo tee /etc/auto.direct
echo '/- /etc/auto.direct' | sudo tee -a /etc/auto.master
sudo systemctl reload autofs; cd /projects && ls

Final checklist: confirm everything works

If every check passes, the ticket is done.

bash
# 1. autofs installed and running
systemctl is-active autofs

# 2. indirect map mounts at /shares/team on access
ls /shares/team; mount | grep team

# 3. direct map mounts at /data/projects on access
ls /data/projects; mount | grep projects

# 4. auto.master has both pointers (/shares and /-)
# 5. all three exam commands written from scratch
# 6. tracker entry checked off

Reply to nfsadmin: autofs configured. Indirect map mounts on /shares/team, direct map at /data/projects, both auto-unmount on idle, service enabled at boot.

next post
Fixing time drift with chrony and the systemd control tools