Mounting NFSv4 share not working with systemd mount

I’m encountering a very strange issue when mounting a nfs share through systemd mount from a trueNAS server. On TrueNAS I have disabled nfs version 3, and only enabled version 4.

The issue that I have, is that when I want to start my systemd mount service, it fails every time, unless I enable NFS version 3 support on trueNAS. My systemd mount file looks as following:

[Unit]
Description=Mount the NFS share for data storage
After=network.target

[Mount]
What=10.0.0.1:/mnt/data-dock/storage
Where=/mnt/data
Type=nfs
Options=_netdev,auto,vers=4.2

[Install]
WantedBy=multi-user.target

However, doing it directly through the command line with the command below works with NFS version 4:

sudo mount -t nfs 10.0.0.1:/mnt/data-dock/storage /mnt/data -o defaults,hard,intr,vers=4.2,_netdev,auto

The logs give me a bit more information:

mount.nfs: access denied by server while mounting 10.0.0.1:/mnt/data-dock/storage

At first I thought that systemd mount for some reason falls back to version 3 and thus is getting the access denied as NFS v3 is disabled on trueNAS, but then I tried mounting a NFS share from a Synology with systemd mount, and it works flawless.
So I’m almost certain that it is a trueNAS issue.

I have tried it with Ubuntu, Rocky linux 9, Debian bookworm and all have the same issue.

Thanks and best regards

So the client is a TrueNAS system or another Linux system?

If it works through the Command Line… isn’t that confirming the TrueNAS works?

The client is a Ubuntu server 24.04. But I have tried with Debian 12, Rokcy Linux 9.5, all have the same issue.

That is what one would assume, but for some reason it is not working with TrueNAS.
With Synology I have no issue, so I know that the issue is not from the client side, but TrueNAS related.

Update: I found that I only get the error when I try to mount the nfs share through the direct link (10gpbs and 9000 MTU) between the client and TrueNAS. When I try connecting through the 1gpbs connection that has wan connection, it works. Still not wiser why this is happening and only with NFS v4.

Direct link may not supoort the discovery protocol??

You’ll have to describe the IP addressing and check whether the clients/protocols work on 10Gbe link.

Update/solution: I made another data set directly under the root data/pool root directory exposed it as NFS share and and it worked flawlessly with systemd mount.

Once I had a confirmation that it should work, I removed both data set that was causing the error and its parent data set (also a NFS share). created a new data set without a parent dataset, exposed it as a NFS share and it worked.