# Cannot mount NFSv4 share



## Peter2121 (Nov 20, 2020)

Hi

I have a NFSv4 share on a server, where I can connect an Ubuntu client, the share is correctly mounted on Ubuntu.
Now I want to mount the same share from another FreeBSD server (both server and client are 12.1 version).
My rc.conf seems to be correct:

```
nfsuserd_enable="YES"
nfscbd_enable="YES"
nfs_client_enable="YES"
```
The permissions are correctly set on server, my IP is in the list of clients for this share.
When I try to mount the share I get an error about the local directory (destination of the mount):

```
# mount_nfs -o nfsv4 -o sec=sys 10.192.20.16:/NFSROOT/GLE-data/bimp/data /mnt/nfs
mount_nfs: nmount: /mnt/nfs: No such file or directory
```
The directory `/mnt/nfs` exists, the owner is root, it is world readable/writable. Idem for `/mnt`.
When I try to truss the command I see the source of the failure:

```
fstatat(AT_FDCWD,"/mnt",{ mode=drwxrwxrwx ,inode=31,size=3,blksize=4096 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
fstatat(AT_FDCWD,"/mnt/nfs",{ mode=drwxrwxrwx ,inode=3125,size=2,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
fstatat(AT_FDCWD,"/mnt/nfs",{ mode=drwxrwxrwx ,inode=3125,size=2,blksize=131072 },0x0) = 0 (0x0)
nmount(0x800675000,16,0x0)                ERR#2 'No such file or directory'
```
The result of `fstatat` system call seems to be OK (0x0), but nmount returns error (!?)
I tried this command from `/root` and from `/`

What's going wrong here??

NOTE: 
The system is installed on ZFS root.


----------



## Peter2121 (Nov 23, 2020)

Finally... I could get it working.
The error is *really* confusing - it was a problem of path on the server (in the `mount` command I used NFSv3 style, so the path was absolute, but for NFSv4 it must be relative to the NFSv4 root).


----------



## dmitrij (Sep 19, 2021)

Could you please clarify what you mean "but for NFSv4 it must be relative to the NFSv4 root"?
I have the same issues with nfsv4 mount.


----------



## Peter2121 (Oct 11, 2021)

dmitrij said:


> Could you please clarify what you mean "but for NFSv4 it must be relative to the NFSv4 root"?
> I have the same issues with nfsv4 mount.


It means that for a directory, exported as follows on NFSv4 server:

```
/NFSROOT/backup/bderp  -sec=sys  -maproot=root  10.192.20.100
```

...I should mount it on 10.192.20.100 like this:

```
10.192.20.16:/backup/bderp /usr/local/data2/db-nfs nfs rw,vers=4,sec=sys 0 0
```

...and NOT like this:

```
10.192.20.16:/NFSROOT/backup/bderp /usr/local/data2/db-nfs nfs rw,vers=4,sec=sys 0 0
```

The root directory on NFSv4 server NFSROOT must not be included in the path passed to mount_nfs.


----------

