| 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 |
| 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 | # https://openzfs.github.io/openzfs-docs/man/master/7/zfsprops.7.html#xattr |
| 25 | # |
| 26 | |
| 27 | |
| 28 | # RAIDZ2 pool creation |
| 29 | # |
| 30 | # -o (lowercase) is a _pool_ setting, -O (uppercase) is a _root dataset_ setting |
| 31 | # |
| 32 | zpool create \ |
| 33 | -o ashift=12 \ |
| 34 | -o autotrim=on \ |
| 35 | -O encryption=on -O keylocation=prompt -O keyformat=passphrase \ |
| 36 | -O pbkdf2iters=1400000 \ |
| 37 | -O acltype=posixacl -O xattr=sa -O dnodesize=auto \ |
| 38 | -O compression=on \ |
| 39 | -O normalization=formD \ |
| 40 | -O atime=off \ |
| 41 | -O longname=on \ |
| 42 | -O canmount=off \ |
| 43 | -O mountpoint=/mnt/$${POOL_NAME} ${POOL_NAME} \ |
| 44 | raidz2 \ |
| 45 | ${DISK1..N} |
| 46 | |
| 47 | |
| 48 | # Dataset creation (benchmarking) |
| 49 | # |
| 50 | # To evaluate which recordsize is most suitable for a certain task we want to hit the raw disk as much as possible. |
| 51 | # Modern OpenZFS versions already allow for direct IO (direct=standard by default), which mostly bypasses ARC/L2ARC. |
| 52 | # In addition we tell ZFS to not hold actual file data in cache, only metadata. |
| 53 | # |
| 54 | zfs create \ |
| 55 | -o canmount=off \ |
| 56 | -o casesensitivity=insensitive \ |
| 57 | -o primarycache=metadata \ |
| 58 | -o secondarycache=metadata \ |
| 59 | ${POOL_NAME}/recordsize-test |
| 60 | zfs create -o recordsize=4K ${POOL_NAME}/recordsize-test/4K |
| 61 | zfs create -o recordsize=8K ${POOL_NAME}/recordsize-test/8K |
| 62 | zfs create -o recordsize=16K ${POOL_NAME}/recordsize-test/16K |
| 63 | zfs create -o recordsize=32K ${POOL_NAME}/recordsize-test/32K |
| 64 | zfs create -o recordsize=64K ${POOL_NAME}/recordsize-test/64K |
| 65 | zfs create -o recordsize=128K ${POOL_NAME}/recordsize-test/128K |
| 66 | zfs create -o recordsize=256K ${POOL_NAME}/recordsize-test/256K |
| 67 | zfs create -o recordsize=512K ${POOL_NAME}/recordsize-test/512K |
| 68 | zfs create -o recordsize=1M ${POOL_NAME}/recordsize-test/1M |
| 69 | zfs create -o recordsize=2M ${POOL_NAME}/recordsize-test/2M |
| 70 | zfs create -o recordsize=4M ${POOL_NAME}/recordsize-test/4M |
| 71 | |
| 72 | |
| 73 | # Dataset creation (media, file server) |
| 74 | # |
| 75 | # casesensitivity=insensitive: Can speed up SAMBA sorting due to SAMBA being case-insensitive as well |
| 76 | # recordsize=XXX Bigger recordsize can yield higher compression ratios (if data is suitable; video files aren't) |
| 77 | # |
| 78 | TODO |
| 79 | |
| 80 | |
| 81 | # Dataset creation (databases) |
| 82 | # |
| 83 | # Common database solutions use 4K (SQLite), 8K (PostgreSQL) or 16KB (MariaDB InnoDB) page sizes. |
| 84 | # Adjusting recordsize to these workloads reduces write amplification and improves random IO. |
| 85 | # Databases usually implement some form of caching themselves, so consider disabling ARC/L2ARC file caching. |
| 86 | # |
| 87 | TODO |
| 88 |
stm / [WIP] ZFS commands
Last active 1 month ago
Commands to create new ZFS pool and datasets on Linux
Revision eb76af04abb7453852c3abce44e19c78a30b5bea