How to create a systemd mount unit

Native systemd mount units are useful when a filesystem needs more than a one-line /etc/fstab entry. They let you attach a mount point to the unit graph, control when it starts, and manage it with the same systemctl workflow used for services, timers, sockets, and automounts.

A *.mount unit is named from the target mount path rather than the source device or directory. That means a mount point such as /srv/archive becomes srv-archive.mount, and the unit's Where= value must match that path exactly. The example below uses a bind mount because it is safe to validate in place, but the same structure applies to local disks, loop devices, and network filesystems by changing What=, Type=, and Options=.

Mount units are system-level objects, so create them as root under /etc/systemd/system. Upstream systemd.mount documentation still treats /etc/fstab as the simpler choice for routine human-managed mounts, while native mount units are a better fit when you need explicit systemd dependencies, drop-ins, or a matching automount unit. A wrong Where= path, filesystem type, or option can still leave the unit in failed state, so verify the file before enabling it.

Steps to create a systemd mount unit:

  1. Convert the target mount path to the escaped unit name that systemd expects.
    $ systemd-escape --path /srv/archive
    srv-archive

    The resulting unit file for /srv/archive is /etc/systemd/system/srv-archive.mount.

  2. Create the source directory and a sample file for the bind-mount example.
    $ sudo mkdir -p /srv/source-archive
    $ sudo touch /srv/source-archive/report-2026.txt

    The example intentionally leaves /srv/archive absent so the mount unit can create the target path from Where= during activation.

  3. Create the mount unit file under /etc/systemd/system.
    [Unit]
    Description=Bind mount for /srv/archive
     
    [Mount]
    What=/srv/source-archive
    Where=/srv/archive
    Type=none
    Options=bind
     
    [Install]
    WantedBy=local-fs.target

    Keep WantedBy=local-fs.target for a normal local mount that should come up during boot. For a network-backed mount, set the real Type= and Options= values and add _netdev when the backend depends on network but the filesystem type alone does not make that obvious to systemd.

  4. Verify that the unit file parses cleanly before reloading the manager.
    $ sudo systemd-analyze verify /etc/systemd/system/srv-archive.mount

    No output means the file syntax, unit name, and required What= and Where= fields were accepted.

  5. Reload the systemd manager after adding the new unit file.
    $ sudo systemctl daemon-reload
  6. Enable the mount unit at boot and start it immediately.
    $ sudo systemctl enable --now srv-archive.mount
    Created symlink /etc/systemd/system/local-fs.target.wants/srv-archive.mount → /etc/systemd/system/srv-archive.mount.

    The [Install] section lets systemctl enable attach the mount to local-fs.target for boot-time activation.

  7. Check the unit state to confirm that the mount succeeded.
    $ systemctl status --no-pager --full srv-archive.mount | head -n 5
    ● srv-archive.mount - Bind mount for /srv/archive
         Loaded: loaded (/etc/systemd/system/srv-archive.mount; enabled; preset: enabled)
         Active: active (mounted) since Mon 2026-04-13 08:41:08 UTC; 3ms ago
          Where: /srv/archive

    The active (mounted) state is the success condition for the unit itself.

  8. List the mount point to confirm that the bind source is exposed through the new path.
    $ ls -ld /srv/archive
    drwxr-xr-x 2 root root 4096 Apr 13 08:41 /srv/archive
    
    $ ls /srv/archive
    report-2026.txt

    If the mount point is empty or the unit enters failed state, inspect journalctl -u srv-archive.mount for the underlying mount helper error.