Tutorial 06 · FreeBSD

ZFS basics: pools, datasets, snapshots, rollbacks

Understand pools and datasets, set properties, and use snapshots to undo mistakes.

Last updated

With the Auto (ZFS) install, your system already lives on a ZFS pool called zroot. This tutorial covers the everyday commands.

1Pools

A pool is built from one or more disks (vdevs). Check health regularly and scrub monthly.

zpool list
zpool status -x       # prints "all pools are healthy" when fine
zpool scrub zroot
zpool history zroot | tail

To create a separate mirrored pool on two spare disks (this erases them):

zpool create tank mirror /dev/ada1 /dev/ada2

2Datasets and properties

Datasets are like flexible filesystems inside a pool. Each can have its own properties, quotas and snapshots.

zfs list
zfs create zroot/data
zfs create -o compression=zstd zroot/data/projects
zfs set quota=50G zroot/data/projects
zfs get compression,used,available,mountpoint zroot/data/projects

Properties are inherited by child datasets. zfs get -s local all zroot/data shows only those set directly.

3Snapshots

A snapshot is a read-only, point-in-time copy. It's instant and only uses space as data changes.

zfs snapshot zroot/data/projects@before-cleanup
zfs snapshot -r zroot/data@daily-2026-10-17   # recursive
zfs list -t snapshot -o name,used,creation

Individual files can be copied out of a snapshot through the hidden .zfs directory:

ls /zroot/data/projects/.zfs/snapshot/before-cleanup/
cp /zroot/data/projects/.zfs/snapshot/before-cleanup/report.txt /zroot/data/projects/

4Rollbacks

Rolling back returns a dataset to a snapshot and discards every change since. By default you can only roll back to the latest snapshot; -r destroys newer snapshots to go further back, so use it with care.

zfs rollback zroot/data/projects@before-cleanup
zfs rollback -r zroot/data/projects@daily-2026-10-17

5Cleaning up

zfs destroy zroot/data/projects@before-cleanup
zfs destroy -nv zroot/data/projects@%daily-2026-10-17   # -n: dry run of a range

← All FreeBSD tutorials