I was setting up NFS on a RockPro64 running the FreeBSD 13 operating system. I ran into an issue where the clients would hang a lot. Apparently the NFS in FreeBSD defaults to v3 and switching to v4 fixed all my problems.
https://www.blissfulidiot.com/2013/06/configuring-nfsv4-on-freebsd.html
This blog post from 2013 shows a basic NFSv4 setup with FreeBSD. To understand the setup I recommend reading these manpages.
Start by setting up exports:
V4: / /export hostname1 hostname2 ... hostnameN
If you need to later adjust the export, run this command to reload the rules:
# killall -HUP mountd
After mounting the filesystem on the clients I noticed the owner and group were incorrect. I reread nfsv4(4) and realized that in order to have the correct uid and gid I need to tweak sysctl.conf:
# on server vfs.nfs.enable_uidtostring=1 vfs.nfsd.enable_stringtouid=1 # on clients vfs.nfs.enable_uidtostring=1
Enable the services on the server in rc.conf:
nfs_server_enable="YES" nfsv4_server_enable="YES"
then start the nfsd service on the server with:
# service nfsd start
Now you should be able to mount the exported folder on the clients you declared in exports. To test mounting manually use the following command:
# mount -t nfs -o nfsv4 server:/export /mnt
If the mount was succesful, nothing gets printed.
Setting the V4 root to the same directory as the one you export will not work, because fstab does not recognize server:/ as a valid filesystem. After reading mount_nfs(8) and fstab(5) I came up with these entries:
# on my workstation # bg prevents the mount from stalling boot process server:/export /export nfs rw,nfsv4,bg 0 0 # and on my laptop # retrycnt=1 limits retries to one server:/export /export nfs rw,nfsv4,bg,retrycnt=1 0 0
I hope this helps you setup your own NAS with NFSv4.