ZFS Setup
apt install zfsutils-linux
Create Pool / Array
zpool create \
-o ashift=12 \
${POOL} \
raidz2 \
/dev/disk/by-id/${DISK_1} \
/dev/disk/by-id/${DISK_2} \
/dev/disk/by-id/${DISK_3} \
/dev/disk/by-id/${DISK_4} \
/dev/disk/by-id/${DISK_5} \
/dev/disk/by-id/${DISK_6}
# enable cache and intent log
zpool add ${POOL} cache -f ${DISK_CACHE}
zpool add ${POOL} log -f ${DISK_LOG}
# set root options
zfs set compression=lz4 ${POOL}
zfs set exec=off ${POOL}
# setup ACLs for NFS clients
# see https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/1779736
zfs set acltype=posixacl ${POOL}
zfs set xattr=sa ${POOL}
Regular Scrub
# monthly scrub - first sunday
0 2 1-7 * * [ $(date +\%w) -eq 0 ] && zpool scrub ${POOL}
Swap on ZFS
zfs create \
-V 32G \
-b $(getconf PAGESIZE) \
-o logbias=throughput \
-o sync=always \
-o compression=off \
-o primarycache=metadata \
-o secondarycache=none \
${POOL}/swap
mkswap -f /dev/zvol/${POOL}/swap
swapon /dev/zfol/${POOL}/swap --discard
cat <<EOF >>/etc/fstab
/dev/zvol/${POOL}/swap none swap defaults,discard 0 0
EOF
Replace a Disk
zpool offline -t ${POOL} ${DISK_OLD}
zpool replace -f ${POOL} ${DISK_OLD} ${DISK_NEW}
Expand Device
zpool online -e ${POOL} ${DISK}
Import Pool From /dev/disk/by-id/*
# list
zpool import -d /dev/disk/by-id/
# import
zpool import -d /dev/disk/by-id/ ${POOL}