Research and Development
Before creating a new pool run zpool destroy
on the pool; it marks a pool as destroyed and disks as free to be used by other ZFS setups. When ZFS adds a disk to the pool, it labels it with its own GUID and some information that allows ZFS to be self-contained.
Disks from a destroyed pool can be added to another pool with the -f
switch used.
$ sudo zpool destroy pool_name
For mirrored pools, a good rule of thumb is to use them only when an incredible read performance or data integrity is needed. With triple mirrors, the capacity will be the total disk’s capacity divided by three, and so on.
$ sudo zpool create -f datapool mirror /dev/ sdb /dev/sdc mirror /dev/sdd /dev/sde mirror /dev/sdf /dev/sdg \
mirror /dev/sdh /dev/sdi mirror /dev/sdj /dev/sdk
For RAIDZ
(which is a rough equivalent of RAID-5 and RAID-6):
* RAIDZ
pools have 2n+1
disks per vdev
(2n
data disks plus 1
disk for parity)
* RAIDZ-2
pools use 2n+2
disks per vdev
(2n
data disks plus 2
disks for parity)
$ sudo zpool create datapool raidz /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf raidz /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk
$ sudo zpool create -f datapool raidz2 /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg \
raidz2 /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm
Hot spares are idle disks added to a pool for replacement in case any active disk in the pool fails. The replacement is done automatically by ZFS.
List all your ZFS pools:
$ sudo zpool list
Get all details about a pool, listed in the previous commands:
$ sudo zpool get all pool_name
If you are unsure about the AL status for your drives, use the smartctl
command:
$ sudo smartctl -a /dev/sda
Print detailed ZFS pool information:
$ sudo zpool status
Perform a quick check by printing only the status of the pools that experienced issues using the -x
option:
$ sudo zpool status -x
View the kernel messages that zed
will listen to by using zpool
events, with or without the -v
switch:
$ sudo zpool events
$ sudo zpool events -v
Several compression algorythms are available on ZFS
pools and datasets. Traditionally, lzjb
has been the default, but as of recently it has been the lz4
algorythm.
Check compression on a ZFS pool:
$ sudo zpool get feature@lz4_compress pool_name
$ sudo zfs get compression pool_name
$ sudo zfs get compressratio pool_name
Enable the lz4 compression for any given dataset:
$ sudo zpool set feature@lz4_compress=enabled pool_name