Skip to main content

ZFS on Linux: Installation, Pools, Snapshots, Clones, and Best Practices

·516 words·3 mins
ZFS Linux Filesystems Storage Sysadmin DevOps
Author
Emre Hayta - System Engineer
Table of Contents

Introduction
#

ZFS is one of the most advanced filesystems ever built — combining a volume manager, RAID functionality, snapshots, checksumming, clones, and self-healing data integrity in one powerful system.
This guide walks you through installing ZFS on Linux, creating pools, working with datasets, snapshots, clones, and maintaining a healthy storage environment.


Why ZFS?
#

ZFS offers features that traditional filesystems (ext4, XFS, btrfs) cannot match:

  • Copy-on-Write (CoW) — no in-place modifications
  • Instant snapshots
  • Clones for testing and VM templates
  • Pooled storage instead of individual partitions
  • Self-healing data with end-to-end checksums
  • Native compression (zstd, lz4)
  • RAID-Z (RAID5/6 replacement)
  • High reliability & data integrity

Installing ZFS on Linux
#

Ubuntu / Debian
#

sudo apt update
sudo apt install zfsutils-linux -y
sudo modprobe zfs

RHEL / Rocky / AlmaLinux
#

sudo yum install epel-release -y
sudo yum install kernel-devel -y
sudo yum install zfs -y
sudo modprobe zfs

Verify Installation
#

zfs --version
zpool --version

Creating ZFS Pools
#

A ZFS pool (“zpool”) aggregates one or more block devices into a single storage pool.

List Available Devices
#

lsblk -o NAME,SIZE,MODEL

Create a Mirrored Pool
#

sudo zpool create tank mirror /dev/sdb /dev/sdc

RAID-Z1 (similar to RAID5)
#

sudo zpool create tank raidz1 /dev/sd{b,c,d}

RAID-Z2 (similar to RAID6)
#

sudo zpool create tank raidz2 /dev/sd{b,c,d,e}

Check Pool Status
#

zpool status
zpool list

Creating Datasets
#

Datasets let you split your pool into manageable, configurable sub-volumes.

sudo zfs create tank/data
sudo zfs create tank/vms
sudo zfs create tank/backups

Recommended Settings#

Enable compression:

sudo zfs set compression=zstd tank/data

Disable atime for performance:

sudo zfs set atime=off tank/data

Show all properties:

zfs get all tank/data

Working With Snapshots
#

Create a Snapshot
#

sudo zfs snapshot tank/data@before-upgrade

List Snapshots
#

zfs list -t snapshot

Delete a Snapshot
#

sudo zfs destroy tank/data@before-upgrade

Rollbacks
#

Rollback a dataset:

sudo zfs rollback tank/data@before-upgrade

⚠️ Warning: All changes after the snapshot will be lost.


Clones
#

Clones are writable copies of snapshots.

Create a Clone
#

sudo zfs clone tank/data@before-upgrade tank/data-test

Remove a Clone
#

sudo zfs destroy tank/data-test

Pool Maintenance & Health
#

Scrub the Pool
#

sudo zpool scrub tank

Check Scrub Status
#

zpool status tank

View Error Stats
#

zpool list -v

Replace a Failing Disk
#

sudo zpool replace tank /dev/sdb /dev/sde

Offline a Disk
#

sudo zpool offline tank /dev/sdb

Online It Again
#

sudo zpool online tank /dev/sdb

Importing & Exporting Pools
#

Export a Pool
#

sudo zpool export tank

List Importable Pools
#

zpool import

Import a Pool
#

sudo zpool import tank

Best Practices for ZFS on Linux
#

  • Use zstd compression
  • Prefer RAID-Z2 for important data
  • Run monthly scrubs
  • Avoid disks of different sizes
  • Split datasets by purpose
  • Automate snapshots with sanoid
  • Never force remove disks
  • Monitor ARC memory usage

Conclusion
#

ZFS is one of the most powerful filesystems available for Linux. With pooled storage, snapshots, clones, and robust integrity guarantees, it is ideal for servers, homelabs, VM hosts, and backup systems.

If you want more guides on ZFS replication, ZVOLs, or integration with Proxmox/KVM/Docker, just let me know!