FreeBSD Fundamentals · Module 08 of 14

ZFS administration and recovery

Work with pools, datasets, properties, snapshots and rollback while understanding operational safety.

Learning objectives

By the end of this module, you should be able to:

  • Distinguish a pool from a dataset.
  • Create snapshots and inspect properties.
  • Use rollback only when its destructive implications are understood.

Pools and datasets

A ZFS pool aggregates storage; datasets are filesystems or volumes created within the pool. Properties such as compression, quota and mountpoint are inherited unless overridden.

Snapshots are point-in-time references

Snapshots are lightweight references to dataset state. They support comparison, cloning and rollback workflows, but rollback can discard newer changes and must be deliberate.

Worked examples

See the idea in practice.

Observe ZFS

zpool status
zfs list
zfs get compression,mountpoint,used,available
  • zpool status reports pool health.
  • zfs list/get reports dataset state and properties.
Hands-on lab

Lab — ZFS pool, snapshot, rollback and cleanup lifecycle

Goal: Create an isolated lab pool on the verified disposable disk, prove snapshot preservation and rollback, then cleanly remove the lab state.

Before you start

  • Disposable VM and the same verified secondary disk after Lab 07 cleanup; NEVER use the boot disk.
  • This lab intentionally rolls data back. Use only the academypool/academy lab dataset.
STEP 1

Verify the disk and create a ZFS partition

# Replace only after positively identifying the disposable second disk:
LABDISK=vtbd1
gpart show "$LABDISK" || true
zpool status
zpool list academypool 2>/dev/null || true

gpart create -s GPT "$LABDISK"
gpart add -t freebsd-zfs -a 1M -l academyzfs "$LABDISK"
gpart show "$LABDISK"
ls -l /dev/gpt/academyzfs
STEP 2

Create the isolated pool and dataset

zpool create academypool /dev/gpt/academyzfs
zpool status academypool
zfs create academypool/academy
zfs set compression=lz4 academypool/academy
zfs get compression,mountpoint academypool/academy
STEP 3

Create baseline data and snapshot

echo before > /academypool/academy/state.txt
cat /academypool/academy/state.txt
zfs snapshot academypool/academy@baseline
zfs list -t snapshot
STEP 4

Change live data and compare with the snapshot

echo after > /academypool/academy/state.txt
printf "live: "; cat /academypool/academy/state.txt
printf "snapshot: "; cat /academypool/academy/.zfs/snapshot/baseline/state.txt
STEP 5

Roll back deliberately and verify recovery

Rollback discards changes made after the selected snapshot. Confirm you are operating only on the disposable Academy dataset.

zfs rollback academypool/academy@baseline
cat /academypool/academy/state.txt
STEP 6

Destroy the lab state

zfs destroy academypool/academy@baseline
zfs destroy academypool/academy
zpool destroy academypool
gpart destroy -F "$LABDISK"
zpool list
gpart show "$LABDISK" || true

Verify

  • Before rollback, the live file says after while the snapshot copy says before.
  • After rollback, the live file again says before.
  • The snapshot, dataset, pool and disposable-disk GPT state are removed during cleanup.

Expected outcome

  • academypool is healthy, compression=lz4 is set on the dataset, and snapshot/rollback behavior is demonstrated with observable file content.
  • Cleanup leaves no academypool behind.

If it fails

  • If zpool create reports existing signatures, stop and inspect the disk instead of forcing pool creation.
  • If .zfs/snapshot is not visible, inspect the snapdir property and confirm the dataset mountpoint before proceeding.
Real-world connection

Snapshots are useful recovery points, but rollback is destructive to newer state and snapshots are not independent backups.

Avoid these traps

Common mistakes

  • Calling a snapshot a backup without considering pool-wide failure.
  • Using rollback before checking what newer data will be lost.
Knowledge check

Can you explain it without looking back?

Open each answer only after you have tried to answer the question yourself.

1What is the difference between a pool and a dataset?

A pool provides storage capacity; datasets are manageable filesystems/volumes within that pool.

2Why are ZFS properties useful?

They let administrators apply storage behavior such as compression, quotas and mountpoints declaratively.

3Why is rollback high-impact?

It can discard changes made after the target snapshot.

My Learning

Record your progress for this module.

Progress is saved in this browser immediately. When you sign in to My Learning, it can also sync across devices.

Not started

Attempt the core lab and knowledge checks before marking the module complete.