20 Jan 2022, 09:23

TrueNAS and NFS

I recently installed TrueNAS and attempted to setup NFS. Here are some notes that may be of use to others or my future self 😄

My use case is to mount the NFS share on demand, backup my home directory, then immediately unmount.

Truenas

Under Services -> NFS:

  1. Enable NFSv4. Because, why not? NFSv4 is better.
  2. Enable ‘NFSv3 ownership model for NFSv4’. This permits UID/GID to be preserved without needing ID mapper running on client side.

Under Sharing -> Unix Shares:

  1. Create a dataset for the NFS share. Be sure to set a quota to something sensible.
  2. Create the NFS share with defaults

Other:

  • Create a TrueNAS user with the same UID as the user that will be using the NFS share
  • Drop into command shell on Truenas and navigate to the new NFS share root. Create a directory under the root and chown it to the user that will use it e.g.
cd /mnt/Seagate4TB/nfsshare
mkdir home-backup
chown ian home-backup

NFS client

  • add an entry to /etc/fstab e.g.
truenas.lan:/mnt/Seagate4TB/nfsshare /mnt	nfs4	noauto,defaults

where /mnt/Seagate4TB/nfsshare/ is the NFS root.

  • add entry to sudoers to enable non-root user to mount the NFS mountpoint:
ian	ALL=(ALL)	NOPASSWD: /usr/bin/mount /mnt, /usr/bin/umount /mnt

Now user ‘ian’ should be able to write into /mnt/home-backup.