NAS Service

ROLES zfs, samba

The NAS service configuration is primarily handled by the "zfs" and "samba" roles. ZFS is used for software raid/mirroring and Samba is used for file sharing to Windows/MacOS clients. Samba is configured on the standard ports.

Everyone's use case will be different, but my need here is a simple home fileserver with a common data area shared among the entire family and individual home areas.

The zfs role creates zpools and filesystems. We just use the default Debian monthly scrub/trim cron job. I trimmed the zfs role to the basics. Look at this role if you want something that does ZVOLs, custom scrubs, zrepl, and other things. We use the following ansible galaxy modules:

If they are not already present, you can install by doing:

% ansible-galaxy collection install community.general

The samba role installs the samba server and creates local accounts with samba access. You can create whatever shares you want, but we can call out certain ones to be owned by the 'nas-data' user and 'nas-data' group for common areas accessible by all users (media files, family pictures, etc.)

Variables

The zfs_pools variable is a list of pools, with a string describing the vdev, along any other settings. It looks something like this.

zfs_pools: 
  - name: tank
    vdev: >-
       mirror 
       ata-BIGDRIVE1
       ata-BIGDRIVE2
       cache
       nvme-FASTDRIVE
Specify pool properties: for a specific ashift, or filesystem_properties: for things like compression or case sensitivity.

The zfs_filesystems variable gives a list of filesystems, with a list of properties. The contents of zfs_filesystems_properties_defaults: are applied to every filesystem.

zfs_filesystems:
  - name: tank/myfs
    properties:
       mountpoint: /myfs
       casesensitivity: mixed

Automatic snapshots are configured through zfs properties, can be set on the pool and will be inherited by all filesystems. Properties are daily, monthly, weekly, hourly, or frequent (~15min). Quote the property value. Quote the true/false When setting the properties in yaml to keep them from being changed to on/off.

    filesystem_properties:   (when setting on zpool)
    properties:
    	"com.sun:auto-snapshot:frequent": "false"
    	"com.sun:auto-snapshot:daily": "true"
    	"com.sun:auto-snapshot:daily": "true,keep=52"

Why These Packages?

The easy path is to buy a commercial NAS, set things up with their web interface and move on. I wanted to build my own box, but did give TrueNAS a try. It was very nice, but intended to be an appliance. I prefer a general purpose machine that serves files, but can easily be used for other things.

I was impressed by ZFS, and wanted to use a simple mirrored setup. Disk sizes have gotten so stupendously huge that I really didn't feel comfortable running a straight ext4 filesystem. I've rarely had disk problems, but resilvering a replacement disk is a lot simpler than finding and restoring double digit terabytes from backups.

Samba is an obvious choice if you are going to support Windows clients. NFS is also an obvious choice if any UNIX machines are in the mix. I originally built this for home use, which is mostly Windows with the occasional Linux box, so we'll see if that is sufficient.

Big Iron Fileserver
Your NAS box should be big iron, like a Pentium 4 box serving out 120G of pure disk goodness.