Mounts (.mount)

Mount a share only when it's accessed (.automount)

3 min · updated June 15, 2026

An .automount unit registers an autofs point: the share isn’t mounted at boot, but the moment a process touches Where=, systemd mounts it on demand. Boots are faster and a dead file server can’t hang startup.

1. The .mount (same as a normal mount)

/etc/systemd/system/mnt-archive.mount:

[Unit]
Description=Archive share

[Mount]
What=nfs-server.internal:/exports/archive
Where=/mnt/archive
Type=nfs
Options=rw,_netdev

Note: no [Install] here — the automount pulls it in.

2. The .automount (same base name)

/etc/systemd/system/mnt-archive.automount:

[Unit]
Description=Automount archive on access

[Automount]
Where=/mnt/archive
TimeoutIdleSec=600

[Install]
WantedBy=multi-user.target

Enable the automount

sudo mkdir -p /mnt/archive
sudo systemctl daemon-reload
sudo systemctl enable --now mnt-archive.automount
# It's NOT mounted yet — touching it triggers the mount:
ls /mnt/archive
findmnt /mnt/archive

Why automount: lazy mounting means a slow or offline NFS/SMB server doesn’t delay boot or block unrelated services, and idle shares free themselves. Gotchas: enable the .automount, never the .mount. The fstab equivalent is the x-systemd.automount mount option, which systemd turns into exactly this pair.

← All recipes