filesystems/zfs.md
... ...
@@ -1,11 +1,60 @@
1 1
# zfs
2 2
3 3
## common commands
4
-| command | description |
5
-| --- | --- |
6
-| `zfs list` | view existing datasets |
7
-| `zfs load-key` | load encryption key |
8
-| `zpool scrub -p <pool>` | pause scrub |
4
+| command | description |
5
+| --- | --- |
6
+| `zfs list` | view existing datasets |
7
+| `zfs load-key` | load encryption key |
8
+| `zfs create` | create new mount point |
9
+| `zfs history` | show complete history of pool |
10
+| `zpool scrub -p <pool>` | pause scrub |
9 11
10 12
## freebsd
11 13
* `zfs` installed as part of base from 13.0
14
+
15
+## my custom setup
16
+* 4x10T disks, one pool with two mirrors
17
+ * gives ~20T usable storage
18
+* prep disks
19
+```
20
+wipefs -a /dev/<disk>
21
+parted /dev/<disk> mklabel gpt
22
+parted /dev/<disk> mkpart "<custom id>" zfs 0% 100%
23
+```
24
+
25
+The `custom id` shows in ZFS, i use a location identifier as below
26
+* 2 character server prefix, `kk` for `kinakuta`
27
+* 2 character enclosure identifier, `e0`, `e1`, etc.
28
+* 2 character disk positon (in my case top to bottom), `d0`, `d1`, etc.
29
+* serial number of the physical disk, taken from the label
30
+
31
+For example
32
+```
33
+root@kinakuta:~# zpool status ~
34
+ pool: crypt.kk
35
+ state: ONLINE
36
+ scan: scrub repaired 0B in 16:50:21 with 0 errors on Tue Apr 15 07:57:21 2025
37
+config:
38
+
39
+ NAME STATE READ WRITE CKSUM
40
+ crypt.kk ONLINE 0 0 0
41
+ mirror-0 ONLINE 0 0 0
42
+ kke0d0-ZS518A9F ONLINE 0 0 0
43
+ kke0d1-ZS518A21 ONLINE 0 0 0
44
+ mirror-1 ONLINE 0 0 0
45
+ kke1d0-ZS518A9D ONLINE 0 0 0
46
+ kke1d1-ZS518A76 ONLINE 0 0 0
47
+
48
+errors: No known data errors
49
+```
50
+
51
+Create zpool
52
+```
53
+zpool create -f -o ashift=12 -o feature@encryption=enabled -O encryption=on -O keylocation=prompt -O keyformat=passphrase -m /path/to/mountpoint <zpool name> mirror /dev/disk/by-partlabel/kke0d0-ZS518A9F /dev/disk/by-partlabel/
54
+kke0d1-ZS518A21 mirror /dev/disk/by-partlabel/kke1d0-ZS518A9D /dev/disk/by-partlabel/kke1d1-ZS518A76
55
+```
56
+
57
+To add spares after pool creation prep them as before then incant
58
+```
59
+zpool add <zpool name> spare /dev/disk/by-partlabel/<part id>
60
+```