stm / [WIP] ZFS commands

Last active 1 month ago

Like 0

Commands to create new ZFS pool and datasets on Linux

Revision a032e43aedb71d297ec2f2480fe2764b74c77003

zfs.txt Raw
1# RAIDZ2 pool creation
2#
3# -o (lowercase) is a _pool_ setting, -O (uppercase) is a _root dataset_ setting
4#
5# ashift=12: 2^12 = 4KiB sectors, for certain NVMe drives use 13 (8KiB)
6# autotrim=on: TRIM for SSDs
7# encryption=on: Defaults to aes-256-gcm (since 0.8.4)
8# pbkdf2iters=1400000: PBKDF2-SHA1 iterations recommendation by OWASP, default is only 350000
9# dnodesize=auto: Is supposed to be used on systems running SAMBA with xattr=sa
10# compression=on: Defaults to lz4 (when lz4_compress is enabled, see `zpool get feature@lz4_compress ${NAME}`)
11# normalization=formD: Decomposed Unicode normalization, implies utf8only=on, so UTF-8 filenames only
12# longname=on: Allows filenames up to 1023 bytes, default is off meaning 255 bytes (supported since 2.3.0)
13# primarycache: Defines what is cached in ARC, defaults to all (alternative settings: none, metadata)
14# secondarycache: Defines what is cached in L2ARC, defaults to all (alternative settings: none, metadata)
15# direct: Unset, defaulting to standard (since 2.3.0)
16# !!! recordsize: Unset, defaulting to 128KiB (important performance related setting!)
17#
18# Sources:
19# https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#pbkdf2
20# https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/Debian%20Trixie%20Root%20on%20ZFS.html#step-2-disk-formatting
21# https://openzfs.github.io/openzfs-docs/man/master/7/zfsprops.7.html#compression
22# https://openzfs.github.io/openzfs-docs/man/master/7/zfsprops.7.html#direct
23# https://openzfs.github.io/openzfs-docs/man/master/7/zfsprops.7.html#dnodesize
24# https://openzfs.github.io/openzfs-docs/man/master/7/zfsprops.7.html#longname
25# https://openzfs.github.io/openzfs-docs/man/master/7/zfsprops.7.html#pbkdf2iters
26#
27#
28zpool create \
29 -o ashift=12 \
30 -o autotrim=on \
31 -O encryption=on -O keylocation=prompt -O keyformat=passphrase \
32 -O pbkdf2iters=1400000 \
33 -O acltype=posixacl -O xattr=sa -O dnodesize=auto \
34 -O compression=on \
35 -O normalization=formD \
36 -O relatime=on \
37 -O longname=on \
38 -O canmount=off \
39 -O mountpoint=/mnt/${NAME} ${NAME} \
40 raidz2 \
41 ${DISK1..N}
42
43
44# Dataset creation
45TODO