====== ZFS ======
====== Format ======
ls -l /dev/disk/by-id
# mirror (advanced format disks: ashift=12)
zpool create -f -o ashift=12 -m /mnt/data POOL_NAME mirror [disk-ID]
zpool status
zpool status -v
====== Dataset ======
# enable encryption feature
zpool set feature@encryption=enabled POOL_NAME
# encrypted dataset with passphrase
zfs create -o encryption=aes-256-gcm -o keyformat=passphrase POOL_NAME/DATASET_NAME
# encrypted dataset with key
dd if=/dev/urandom of=/tmp/key bs=1 count=32
zfs create -o encryption=aes-256-gcm -o keyformat=raw -o keylocation=file:///tmp/key POOL_NAME/DATASET_NAME
# load key
zfs load-key POOL_NAME/DATASET_NAME
# mount all
zpool import -a -f
zfs mount -a
# get property
zfs get -p encryption,keylocation
# delete dataset
zfs destroy POOL_NAME/DATASET_NAME
====== Scrub ======
zpool scrub POOL_NAME
# scrub once a week
crontab -e
0 6 * * 1 zpool scrub POOL_NAME
====== Qouta ======
zfs set quota=100M zroot/usr/home/username
zfs list
zfs get quota zroot/usr/home/username
====== Snapshot ======
===== Manual =====
zfs snapshot tank/pool@snapshot
zfs rename tank/pool@snapshot tank/pool@snapshot-renamed
zfs rollback tank/pool@snapshot-renamed
zfs destroy tank/pool@snapshot-renamed
===== Scheduled =====
yaourt znapzend
znapzendzetup create --recursive SRC '7d=>1h,30d=>6h,60d=>1d' tank/pool
znapzend --debug --runonce tank/pool
zfs list -t snapshot
systemctl enable znapzend
systemctl start znapzend
Ref
* https://docs.oracle.com/cd/E23823_01/html/819-5461/gazvb.html
* https://lildude.co.uk/zfs-cheatsheet
* https://wiki.archlinux.org/index.php/ZFS
* https://blog.heckel.xyz/2017/01/08/zfs-encryption-openzfs-zfs-on-linux/