ZFS nice commands

From Lolly's Wiki
Revision as of 00:57, 26 November 2021 by Lollypop (talk | contribs) (Text replacement - "<source " to "<syntaxhighlight ")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


Some ZFS commands I use often (on Linux)

zpool

Get zpool status

# zpool status -P
  pool: rpool
 state: ONLINE
  scan: scrub repaired 0B in 0h41m with 0 errors on Tue Nov 27 11:49:30 2018
config:

	NAME                                                           STATE     READ WRITE CKSUM
	rpool                                                          ONLINE       0     0     0
	  /dev/disk/by-id/ata-SanDisk_SDSSDHII960G_151740411091-part4  ONLINE       0     0     0
  • -P : Display real paths for vdevs instead of only the last component of the path.
# zpool status -PL
  pool: rpool
 state: ONLINE
  scan: scrub repaired 0B in 0h41m with 0 errors on Tue Nov 27 11:49:30 2018
config:

	NAME         STATE     READ WRITE CKSUM
	rpool        ONLINE       0     0     0
	  /dev/sda4  ONLINE       0     0     0

errors: No known data errors
  • -P : Display real paths for vdevs instead of only the last component of the path.
  • -L : Display real paths for vdevs resolving all symbolic links.

Get zpool size

# zpool list
NAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
rpool   788G   609G   179G         -    53%    77%  1.00x  ONLINE  -

Ooooh... bad fragmentation! So what? It's a SSD!

Get the ashift value

# zpool list -o name,ashift
NAME   ASHIFT
rpool       9

which means 2^9=512 := 512 byte blocks in the backend... that is uncool for SSDs.

# echo $[ 2 ** 12 ]
4096

# zpool set ashift=12 rpool
# zpool list -o name,ashift
NAME   ASHIFT
rpool       12

which means 2^12=4096 := 4k blocks in the backend. Perfect!

zfs

zdb

Traverse all blocks

# zdb -b rpool

Traversing all blocks to verify nothing leaked ...

loading space map for vdev 0 of 1, metaslab 196 of 197 ...
 609G completed (4928MB/s) estimated time remaining: 0hr 00min 00sec        
	No leaks (block sum matches space maps exactly)

	bp count:        32920989
	ganged count:           0
	bp logical:    760060348928      avg:  23087
	bp physical:   650570102784      avg:  19761     compression:   1.17
	bp allocated:  654308115456      avg:  19875     compression:   1.16
	bp deduped:             0    ref>1:      0   deduplication:   1.00
	SPA allocated: 654308115456     used: 77.33%

	additional, non-pointer bps of type 0:     237576
	Dittoed blocks on same vdev: 1230844