stm / [WIP] ZFS commands

Last active 1 month ago

Like 0

Commands to create new ZFS pool and datasets on Linux

Revision 78743a7fb286b011c08e8d9f62a25599ffb2089f

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