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
Steps to mount an NFS export with a systemd mount unit:
- Install the NFS client utilities on the Linux client if mount.nfs is not already available.
$ sudo apt install --assume-yes nfs-common
Use sudo dnf install nfs-utils on RHEL, CentOS Stream, Fedora, and compatible systems.
- Query the server's export list from the client network.
$ 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 - Create the empty local mount point.
$ sudo mkdir --parents /mnt/projects
Files already inside /mnt/projects become hidden while the NFS filesystem is mounted there.
- Mount the export manually with the options planned for the unit.
$ 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.
- Verify that the manual mount uses the expected server export.
$ 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.
- List the mounted directory as a user who should have access.
$ 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.
- Unmount the manual test mount.
$ sudo umount /mnt/projects
- Generate the mount-unit filename from the mount point.
$ systemd-escape --path --suffix=mount /mnt/projects mnt-projects.mount
The resulting unit file for /mnt/projects is /etc/systemd/system/mnt-projects.mount.
- Create the native mount unit file.
$ 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=.
- Verify the unit file before reloading systemd.
$ sudo systemd-analyze verify /etc/systemd/system/mnt-projects.mount
No output means systemd accepted the unit syntax, filename, and required mount settings.
- Reload the systemd manager after saving the unit.
$ sudo systemctl daemon-reload
- Enable the mount unit for boot and start it now.
$ 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.
- Check that systemd reports the mount unit as active and mounted.
$ 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.
- Verify that the live mount table shows the expected NFS source.
$ findmnt -o TARGET,SOURCE,FSTYPE /mnt/projects TARGET SOURCE FSTYPE /mnt/projects files.example.net:/srv/nfs/projects nfs4
- List the mounted path through the unit-managed mount.
$ ls /mnt/projects README.txt reports
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.