Quoted Strings

NFS File Sharing and ZFS Monitoring

  2025/06/29

Posted Tag: #Linux
Other Tags: #Windows, #Personal, #All

NFS File Sharing

I use NFS for file sharing. I do not use SAMBA mainly because I have Sophos UTM software as a firewall. NFS is not a secure as SAMBA but I only share in my local network.

On the server set the owner of the ZFS pools allowing sharing with Linux and Windows. Otherwise the permissions are for root access.

chown -R server:server tank/
chown -R server:server dozer/

We can now install NFS and share the pools. Use your IP address for the shares. Copy and and paste into the NFS exports file.

sudo apt install nfs-kernel-server

sudo nano /etc/exports

tank/ 192.168.00.00/24(rw,no_root_squash,no_subtree_check,anonuid=1000,anongid=1000)
dozer/ 192.168.00.00/24(rw,no_root_squash,no_subtree_check,anonuid=1000,anongid=1000)

If mounting the shares using a Linux client

Install NFS and create directories for mounting giving your user name proper permission. You can mount the pools automatically at boot or manually using the script that follows.

sudo pacman -S nfs-utils

sudo mkdir /mnt/tank
sudo mkdir /mnt/dozer

sudo chown -R user:user /mnt/tank
sudo chown -R user:user /mnt/dozer

To automatically mount the pools modify fstab as below using your server IP address.

sudo nano /ect/fstab

192.168.00.00:/tank    /mnt/tank    nfs    defaults,auto,nofail,x-gvfs-show,x-gvfs-name=tank    0    0
192.168.00.00:/dozer    /mnt/dozer    nfs    defaults,auto,nofail,x-gvfs-show,x-gvfs-name=dozer    0    0

To manually mount the pools modify fstab as below.

sudo nano /ect/fstab

192.168.00.00:/tank    /mnt/tank    nfs    defaults,noauto,nofail,x-gvfs-show,x-gvfs-name=tank    0    0
192.168.00.00:/dozer    /mnt/dozer    nfs    defaults,noauto,nofail,x-gvfs-show,x-gvfs-name=dozer    0    0

Use this script I call mount_server_tank using your server IP address. Be sure to make the file executable with chmod +x mount_server_tank. I have one for dozer too.

#!/bin/bash

sudo mount -t nfs 192.168.00.00:/tank /mnt/tank
exit

If mounting the shares using a Windows client

To install NFS, type Control Panel in the Start Menu Search and then choose Programs and Features. Choose Turn Windows features on and off on the left. Check the boxes below for NFS and click OK.

Enable NFS

Open File Explorer, right-click My Computer on the left and choose Mount Network Drive.

Mount network drive

Type \\\192.168.00.00 using your server IP address and click Browse. You should see the shared pools on the server and in my case I chose tank above. The shared drive will show up in File Explorer.

ZFS Monitoring

On the server first Implement email notifications. I use mailgun.org for this. I use their free service since I may get two emails a month, one about each pool.

sudo apt install mailutils msmtp msmtp-mta

Now setup for email. Enter what you get from mailgun's site.

sudo nano /etc/msmtprc

defaults
auth           on
tls            on
tls_starttls   off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        ~/msmtp.log

account alerts
host smtp.mailgun.org
port 465
from [email protected]
user [email protected]
password XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXX-XXXXXXXX

account default : alerts

To test email. -s = send to and -r = sender

mail -s "Test subject" [email protected] -r [email protected]

On CC: chose Enter

Type anything, chose enter

Chose CTRL + D on keyboard to finish sending e-mail

To enable ZFS monitoring change the contents of the below file. -r = sender

sudo nano /etc/zfs/zed.d/zed.rc

ZED_EMAIL_ADDR="[email protected]"
ZED_EMAIL_PROG="mail"
ZED_EMAIL_OPTS="-s '@SUBJECT@' @ADDRESS@ -r [email protected]"
ZED_NOTIFY_VERBOSE=1

sudo systemctl enable --now zfs-zed

Wish to add a comment? Please include your name to display in your comment or anonymous.

Your email address will never be shared with anyone.

Email me a comment to post it.