User Tools

Site Tools


  • zfsreminders
  • Jonathan Haack
  • Haack's Networking


Create a pool on a single drive and specify a mountpoint for it. Note: use id, not uuid.

zpool create -m /mnt/Pool Pool -f /dev/disk/by-id/b592...

If you have more than one drive to begin with, you can make mirrors as follows:

zpool create -m /mnt/Pool Pool -f mirror /dev/disy/by-id/2323... /dev/disy/by-id/3232...

If you accidentally used short names, then export and import to change it asap like this:

zpool export vms 
zpool import -d /dev/disk/by-id vms

If you messed up and picked a wrong name and/or mountpoint, adjust later as follows. To rename:

zpool export [pool_name]
zpool import [original_pool_name] [new_pool_name]

To change mountpoint:

zfs set mountpoint=/myspecialfolder mypool

If you now have more than one drive, add another drive as a mirror as follows:

zpool attach nameofpool /dev/disk/by-id/currentdisk /dev/disk/by-id/newdisk

To create an encrypted dataset you generate a key and then specify the location and name of the pool as follows:

dd if=/dev/random of=/secure/area/example.key bs=1 count=32
zfs create -o encryption=on -o keyformat=raw -o keylocation=file:///mnt/vault/example.key pool/dataset

After reboot, import (mount), the data set as follows:

zfs load-key pool/dataset
zfs mount pool/dataset

To create snapshots, here is a reasonable template:

DATE=`date +"%Y%m%d-%H:%M:%S"`
/usr/sbin/zfs snapshot -r pool/dataset@backup_$DATE

To delete all snapshots and start over:

zfs list -H -o name -t snapshot | xargs -n1 zfs destroy

To add a zfs cache or slog hard drive to your pool, do the following:

zpool add pool cache /dev/disk/by-id/3434...
zpool add pool log /dev/disk/by-id/3434...

To view current snapshots, do the following:

zfs list -r -t snapshot -o name,creation pool/dataset
zfs list -r -t snapshot -o name,creation pool

To view pool space, including snapshots, do the following:

zfs list -ro space

To replace a failed drive, power down the host, remove drive, reboot, get by-id of the new drive, and run zpool status -v for hard drive number of old drive, then do:

sudo zpool replace pool <hard-drive-number> /dev/disk/by-id/</dev/disk/by-id/newdrive>
sudo zpool replace pool 3347762980558930904 /dev/disk/by-id/ata-WDC_WD...

To check the health, statistics, and basic specs of your pool:

zpool status -v
zpool iostat -v
zpool list

Also, ….

oemb1905 2022/08/06 19:43

computing/zfsreminders.txt · Last modified: 2022/08/08 12:54 by oemb1905