What is ZFS?
ZFS (Zettabyte File System) is a combined filesystem and volume manager originally developed by Sun Microsystems. It provides:
- Data integrity - End-to-end checksums detect corruption
- Pooled storage - Combine multiple disks into a single pool
- Snapshots - Instant point-in-time copies
- Compression - Transparent compression
- RAID - Built-in software RAID (RAID-Z1, Z2, Z3)
- Deduplication - Optional block-level dedup
- Copy-on-write - No risk of partial writes
Key Concepts
Pools (zpools)
The foundation of ZFS storage. A pool combines one or more virtual devices (vdevs) into a single storage unit.
# View pools
zpool list
# Pool status with disk info
zpool status
# Example output:
# pool: zroot
# state: ONLINE
# config:
# NAME STATE READ WRITE CKSUM
# zroot ONLINE 0 0 0
# da0p3 ONLINE 0 0 0Datasets
ZFS filesystems within a pool. Each dataset can have its own properties (compression, quota, etc.).
# List datasets
zfs list
# Example output:
# NAME USED AVAIL REFER MOUNTPOINT
# zroot 10.5G 89.5G 96K /zroot
# zroot/ROOT 5.2G 89.5G 96K none
# zroot/ROOT/default 5.2G 89.5G 5.2G /
# zroot/home 2.1G 89.5G 2.1G /homeSnapshots
Read-only point-in-time copies of a dataset. Snapshots are nearly instant and space-efficient.
# Create snapshot
zfs snapshot zroot/home@backup-2025-01-15
# List snapshots
zfs list -t snapshot
# Rollback to snapshot
zfs rollback zroot/home@backup-2025-01-15RAID-Z Levels
| Level | Disks Min | Parity | Comparison |
|---|---|---|---|
| Mirror | 2 | N/A | Like RAID 1 |
| RAID-Z1 | 3 | 1 disk | Like RAID 5 |
| RAID-Z2 | 4 | 2 disks | Like RAID 6 |
| RAID-Z3 | 5 | 3 disks | No equivalent |
Common Properties
# Enable compression (lz4 recommended)
zfs set compression=lz4 zroot/home
# Set quota
zfs set quota=50G zroot/home/user
# Enable access time recording
zfs set atime=off zroot # Improves performance
# Check compression ratio
zfs get compressratio zroot/homeWhy ZFS on FreeBSD?
FreeBSD has first-class ZFS support:
- Native kernel module (not FUSE)
- Boot from ZFS
- Root-on-ZFS with boot environments
- Well-tested and production-ready
- OpenZFS project keeps it current
- zfs
- filesystem
- freebsd
- storage
- raid
- snapshots