💾 Archived View for kallinen.xyz › comfy-home-nas-setup-with-nfsv4 captured on 2022-03-01 at 15:38:09. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-01-08)

-=-=-=-=-=-=-

Comfy home NAS setup with NFSv4

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.

nfsv4(4)

exports(5)

Setup

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.

fstab woes

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:

mount_nfs(8)

fstab(5)

# 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.