ZFS

From Pulsed Media Wiki

ZFS

ZFS (Zettabyte File System) is a combined file system and logical volume manager designed to provide high storage capacities, data integrity, and advanced management features. Originally developed by Sun Microsystems for the Solaris operating system, ZFS is now available on multiple platforms, including FreeBSD, Linux (via OpenZFS), and others.

ZFS is known for its reliability, scalability, and advanced features, making it popular in enterprise storage, servers, and high-performance NAS systems.

Key Features

  • Copy-on-Write (COW) – Prevents data overwrites by writing changes to new blocks, allowing for safe snapshots and high data integrity.
  • Data Integrity and Checksumming – Every block of data and metadata is checksummed, ensuring automatic detection and correction of silent data corruption.
  • Pooled Storage – Combines multiple physical devices into a single storage pool (zpool), simplifying volume management.
  • Snapshots and Clones – Create instant, space-efficient snapshots and writable clones.
  • Native Compression – Supports multiple algorithms, including LZ4 and gzip, for transparent on-the-fly compression.
  • RAID-Z – A custom implementation of RAID that avoids the "write hole" problem. Supports RAID-Z1 (single parity), RAID-Z2 (double parity), and RAID-Z3 (triple parity).
  • Scalability – Supports extremely large file systems, up to 256 quadrillion zettabytes (theoretically).
  • Efficient Deduplication – Optionally removes duplicate data blocks to save space.
  • Self-healing Data – Automatically repairs damaged data using redundant copies.

Terminology

  • zpool – A logical storage pool made from one or more devices.
  • vdev – A virtual device that contributes storage to a pool.
  • dataset – A file system or volume created within a zpool.
  • snapshot – A read-only point-in-time copy of a dataset.
  • clone – A writable copy of a snapshot.

Usage Examples

Create a basic ZFS pool:

<syntaxhighlight lang="bash"> sudo zpool create mypool /dev/sdb /dev/sdc </syntaxhighlight>

Create a ZFS filesystem:

<syntaxhighlight lang="bash"> sudo zfs create mypool/data </syntaxhighlight>

Take a snapshot:

<syntaxhighlight lang="bash"> sudo zfs snapshot mypool/data@snapshot1 </syntaxhighlight>

Rollback to snapshot:

<syntaxhighlight lang="bash"> sudo zfs rollback mypool/data@snapshot1 </syntaxhighlight>

Enable compression:

<syntaxhighlight lang="bash"> sudo zfs set compression=lz4 mypool/data </syntaxhighlight>

Advantages

  • High data integrity and fault tolerance
  • Simplified storage management
  • Advanced features like native RAID, snapshots, and clones
  • Excellent scalability for modern storage needs

Limitations

  • High memory usage (recommended 1 GB RAM per 1 TB of storage)
  • More complex than traditional filesystems
  • Not included in the Linux kernel due to licensing (uses a kernel module via OpenZFS)
  • Recovery from pool failure is difficult without backups

Comparison Table

Common Use Cases

  • Enterprise storage and data centers
  • High-performance NAS and SAN systems
  • Backup and archival systems
  • Virtualization hosts (e.g., Proxmox VE)
  • Personal or home servers using ZFS on Linux or FreeBSD

Distributions Supporting ZFS

  • FreeBSD (native)
  • Ubuntu (ZFS on root supported)
  • Debian (via OpenZFS)
  • Proxmox VE (ZFS as default)
  • TrueNAS (based on FreeBSD/OpenZFS)

See Also

Feature ZFS Btrfs ext4 XFS
Copy-on-write Yes Yes No No Checksumming Yes (data + metadata) Yes Metadata only Metadata only Snapshots Yes Yes No No RAID support Yes (RAID-Z) Yes No No Compression Yes Yes No No Deduplication Yes Yes (limited) No No Max file size 16 EiB 16 EiB 16 TiB 8 EiB Online resize Grow only Grow/shrink Grow/shrink Grow only Platform Linux (OpenZFS), FreeBSD, Illumos Linux Linux Linux License CDDL (OpenZFS) GPL GPL GPL