Skip to content

Instantly share code, notes, and snippets.

@bitsandbooks
Last active January 18, 2025 16:07
Show Gist options
  • Save bitsandbooks/0505d37084a3f2bebdbbd50a2c61986f to your computer and use it in GitHub Desktop.
Save bitsandbooks/0505d37084a3f2bebdbbd50a2c61986f to your computer and use it in GitHub Desktop.
Creating a ZFS pool
# General Settings
# My pool lives behind an IBM M1015 host bus adapter, which comes with
# two SAS ports, each of which supports four SAS or SATA disks. These
# settings apply to it.
multipath no
topology sas_direct
phys_per_port 4
slot phy
# Aliases
# NOTE: **NEVER** use sda, sdb, sdc; these can change between boots.
# Use the disk's identifier instead, as it appears in `/dev/disk/by-id`.
# Once this is done, you can refer to devices in ZFS operations using
# the friendly aliases you've created.
# ALIASES UNIQUE DEVICE IDS
alias trunk1 wwn-0x8000c40012345678
alias trunk2 wwn-0x8000c40081234567
alias trunk3 wwn-0x8000c40078123456
alias trunk4 wwn-0x8000c40067812345
alias trunk5 wwn-0x8000c40056781234
alias trunk6 wwn-0x8000c40045678123
alias system nvme-eui.00123456789abcde
# zpool create
# ZFS pool options (note lowercase `-o` flag):
# -o ashift=12 # use 4K sectors
# -o autoexpand=on # if all disks replaced, expand to fill new storage
# -o autotrim=on # performance: on for SSDs, off for spinning rust
# ZFS (first) filesystem options (note uppercase `-O` flag):
# -O acltype=posix # use unix-style access control lists
# -O atime=off # don't update access time for files when read (performance)
# -O compression=zstd # use newer zstd compression
# -O xattr=sa # use system-available extended attributes
# -O dnodesize=auto # if `xattr=sa` set and workload makes heavy use of xattrs
# -O normalization=formD # unicode normalization
# -O com.sun:auto-snapshot=false # for zfs-auto-snapshot
# REQUIRED: pool mount point (note lowercase `-m` flag):
# -m /var/local
# REQUIRED: pool name
# trunk
# REQUIRED: Storage vdev; six spinning-rust disks in RAID-Z2 (RAID-6) configuration
# raidz2 trunk1 trunk2 trunk3 trunk4 trunk5 trunk6
# OPTIONAL: Cache vdev; partition on fast SSD
# cache system-part4
# OPTIONAL: Log vdev; partition on fast SSD
# log system-part3
zpool create \
-o ashift=12 \
-o autoexpand=on \
-o autotrim=on \
-O acltype=posix \
-O atime=off \
-O compression=zstd \
-O dnodesize=auto \
-O normalization=formD \
-O xattr=sa \
-O com.sun:auto-snapshot=false \
-m /var/local
trunk \
raidz2 trunk1 trunk2 trunk3 trunk4 trunk5 trunk6 \
cache system-part4 \
log system-part3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment