NFS exports with ZFS

If you have a ZFS based storage server and other machines in the network, it would be a shame not to share the awesome storage with them.

I have 2 servers at home.
frisbie is the ZFS storage machine and yotta is just a powerful machine but with only one disk, so I’d like to run VMs on it but I’d also like to avoid crying whenever the disk on it dies 🙂

First, enable and start up all the required daemons for NFS server to function.

sysrc -f /etc/rc.conf nfs_server_enable="YES"  
sysrc -f /etc/rc.conf rpc_lockd_enable="YES"  
sysrc -f /etc/rc.conf rpc_statd_enable="YES"  
for service in {nfsd,statd,lockd}; do service $service start; done  

So I create a new zfs filesystem on Frisbie

zfs create data/yotta_bhyve  

And then set it to be shared via NFS:

zfs set sharenfs="-maproot=root yotta,rw" data/yotta_bhyve  

The maproot option on FreeBSD is the same as nosquashroot on linux. Since I will be using it as root on my client I need it to work. Might not be elegant, but hey…

On the client:

sysrc -f /etc/rc.conf nfs_client_enable="YES"  
service nfsclient start  
mkdir /bhyve  
mount frisbie:/data/yotta_bhyve /bhyve  

And afterwards it makes sense to add something like this to /etc/fstab

frisbie:/data/yotta_bhyve /bhyve        nfs     rw      0       0