1 # ZFS
   2 
   3 DRIVES=$(echo /dev/sd{a..j})
   4 
   5 for i in $DRIVES; do
   6     # Clear any existing partition table
   7     echo sudo sgdisk --zap-all $i
   8     echo sudo sgdisk --largest-new=1 $i
   9 done
  10 
  11 # TODO: should give whole disks to ZFS
  12 
  13 DRIVE_PARTITIONS=$(echo /dev/sd{e,d,c,f,h,g,i,j}1)
  14 
  15 NAME=archive
  16 
  17 CACHE_DISKS="nvme-SAMSUNG_MZQL2960HCJR-00A07*-part3"
  18 DATA_DISKS="ata-TOSHIBA_MG08ACA16TEY_*"
  19 
  20 ## create main array, 1-disk party raidz
  21 # use ashift=12 for 4K sector disks
  22 sudo zpool create -o ashift=12 -f $NAME raidz /dev/disk/by-id/${DATA_DISKS}
  23 
  24 # no parity disk raid0 equivalent
  25 sudo zpool create -o ashift=12 -f $NAME /dev/disk/by-id/${DATA_DISKS}
  26 
  27 ## add cache
  28 sudo zpool add -f $NAME cache /dev/disk/by-id/${CACHE_DISKS}
  29 
  30 ## list devices
  31 zpool status -v
  32 
  33 sudo zfs set xattr=sa ${NAME}
  34 sudo zfs set compression=lz4 ${NAME}
  35 sudo zfs set atime=off ${NAME}
  36 sudo zfs set relatime=off ${NAME}
  37 # See https://blog.programster.org/zfs-record-size about setting recordsize
  38 #sudo zfs set recordsize=16K ${NAME}  # For BitTorrent
  39 sudo zfs set recordsize=1M ${NAME}   # For long-term storage
  40 # Deduplication. Requires system w/ large amount of RAM
  41 sudo zfs set dedup=on ${NAME}
  42 
  43 ## show pool information from member device, e.g. /dev/sde
  44 sudo zdb -l /dev/sde1
  45 
  46 ## get all parameters
  47 sudo zfs get all ${NAME}
  48 
  49 
  50 ROOT=/mnt
  51 
  52 mount /dev/md1 /mnt
  53 mount /dev/md0 /mnt/boot
  54 mount -o bind /proc /mnt/proc
  55 mount -o bind /sys /mnt/sys
  56 mount -o bind /run /mnt/run
  57 mount -o bind /dev /mnt/dev
  58 
  59 installimage -n geta -r yes -l 1 -p /boot:ext3:1G,/:xfs:128G -f yes -t yes -d nvme0n1,nvme1n1 -i /root/images/Debian-1101-bullseye-amd64-base.tar.gz

References

https://pthree.org/2012/04/17/install-zfs-on-debian-gnulinux/

https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Workload%20Tuning.html#bit-torrent

ZFS RAIDZ stripe width, or: How I Learned to Stop Worrying and Love RAIDZ: Use RAID-Z. Not too wide. Enable compression.

dRAID, Finally!: Intro to dRAID, ZFS RAID w/ fixed record size to enable faster resilvers.

SamatsWiki: ZFS (last edited 2023-09-29 23:02:16 by SamatJain)