ZFS Pool & Dataset notes

Some notes on ZFS pools & datasets on FreeBSD

Create a ZFS Pool on a specific device

zpool create <pool name> <device name>

For example, create a pool called zfs-pool on disk device /dev/da2:

zpool create zfs-pool /dev/da2

Create a ZFS Dataset in a ZFS Pool

zfs create <pool name>/<dataset name>

For example, create a dataset called dataset in the ZFS Pool zfs-pool created above

zfs create zfs-pool/dataset

Set mountpoint

This will set the mountpoint for either a ZFS Pool or Dataset, depending upon the target

zfs set mountpoint=</path/to/mountpoint> <zfs pool>/<zfs dataset>

For example, to mount the dataset called dataset in the ZFS Pool zfs-pool at /mnt/dataset

zfs set mountpoint=/mnt/dataset zfs-pool/dataset

Set compression type

This will set the compression type for either a ZFS Pool or Dataset, depending upon the target

zfs set compression=<compression type> <zfs pool>/<zfs dataset>

Compression type can be one of:

  • gzip
  • lz4
  • others

Which is best for you varies, but for general purpose I find lz4 the best option

For example, to set lz4 compression on the whole pool zfs-pool created above, use:

zfs set compression=lz4 zfs-pool

Alternatively, to set gzip compression specifically on the dataset dataset' use:

zfs set compression=gzip zfs-pool/dataset

Previous Post Next Post