An NFS mount unit lets systemd manage a remote export as a named mount instead of relying only on a persistent mount table entry. It fits Linux clients where one export needs direct systemctl lifecycle commands, explicit network ordering, or later drop-ins for dependency and timeout policy.
A native *.mount file is named from the local mount path in Where=, not from the server name or export path. Generate the unit name from the mount point before writing the file so the filename and Where= value stay aligned.
Start from an export that already mounts manually from the client. The setup is ready when systemd accepts the unit file, the mount unit reaches active plus mounted, and findmnt shows the expected server export at the local mount point.
Related: How to mount an NFS export on Linux
Related: How to automatically mount an NFS export on Linux
Related: How to create a systemd mount unit
Related: How to create a systemd automount unit
$ sudo apt install --assume-yes nfs-common
Use sudo dnf install nfs-utils on RHEL, CentOS Stream, Fedora, and compatible systems.
$ showmount --exports files.example.net Export list for files.example.net: /srv/nfs/projects 192.0.2.0/24
Some NFSv4-only servers do not answer showmount because they do not expose the legacy mount service. If the server owner provided the exact export path, test the mount directly and compare any failure with the server-side export table.
Related: How to list NFS exports from a client
Related: How to list NFS exports on a server
$ sudo mkdir --parents /mnt/projects
Files already inside /mnt/projects become hidden while the NFS filesystem is mounted there.
$ sudo mount -t nfs -o rw,hard,vers=4.2 files.example.net:/srv/nfs/projects /mnt/projects
Replace files.example.net:/srv/nfs/projects with the server and export path assigned by the NFS server owner. Add server-required options such as sec=krb5p before saving the unit file.
$ findmnt -o TARGET,SOURCE,FSTYPE /mnt/projects TARGET SOURCE FSTYPE /mnt/projects files.example.net:/srv/nfs/projects nfs4
A mounted NFSv4 export can appear as nfs4 in the live mount table even when the command and unit use nfs with a vers= option.
$ ls /mnt/projects README.txt reports
If the mount succeeds but files cannot be read or written, check the server export rule, filesystem permissions, UID/GID mapping, and any Kerberos security option required by the export.
$ sudo umount /mnt/projects
$ systemd-escape --path --suffix=mount /mnt/projects mnt-projects.mount
The resulting unit file for /mnt/projects is /etc/systemd/system/mnt-projects.mount.
$ sudoedit /etc/systemd/system/mnt-projects.mount
[Unit] Description=Mount NFS projects export Wants=network-online.target After=network-online.target [Mount] What=files.example.net:/srv/nfs/projects Where=/mnt/projects Type=nfs Options=rw,_netdev,hard,vers=4.2 DirectoryMode=0755 TimeoutSec=30s [Install] WantedBy=remote-fs.target
_netdev marks the export as a network mount for systemd ordering. Use TimeoutSec= in a native mount unit because fstab-only options such as x-systemd.mount-timeout= are ignored inside Options=.
$ sudo systemd-analyze verify /etc/systemd/system/mnt-projects.mount
No output means systemd accepted the unit syntax, filename, and required mount settings.
$ sudo systemctl daemon-reload
$ sudo systemctl enable --now mnt-projects.mount Created symlink /etc/systemd/system/remote-fs.target.wants/mnt-projects.mount -> /etc/systemd/system/mnt-projects.mount.
Add nofail to Options= only when the export is optional for this client. A critical application path should fail visibly if the server export cannot mount.
$ systemctl show -p ActiveState -p SubState mnt-projects.mount ActiveState=active SubState=mounted
If the unit enters failed, inspect sudo journalctl -u mnt-projects.mount -b and retest the manual mount.
$ findmnt -o TARGET,SOURCE,FSTYPE /mnt/projects TARGET SOURCE FSTYPE /mnt/projects files.example.net:/srv/nfs/projects nfs4
$ ls /mnt/projects README.txt reports