Guideschevron_rightStorage

Storage · 7 min read · Updated

ZFS vs Btrfs vs RAID

ZFS and Btrfs are copy-on-write file systems that checksum every block, so they can detect silent corruption and, with a second copy, repair it; both also take instant snapshots. Plain RAID (mdadm or a hardware controller) only keeps drives in step and cannot tell which copy is correct when they disagree. Choose ZFS for a NAS or storage server, especially with parity RAID; Btrfs for a single disk or a mirror where you want snapshots without an out-of-tree kernel module; and mdadm RAID with ext4 or XFS when you want the simplest, most widely understood setup.

Side by Side

ZFS, Btrfs and RAID compared
AspectZFSBtrfsRAID (mdadm or hardware)
Detects silent corruptionYes, checksums on every blockYes, checksums on every blockNo
Repairs itYes, from a mirror or parityYes, from a mirror (RAID1/10)No: cannot tell which copy is right
SnapshotsYes, instantYes, instantNo (add LVM or a snapshotting file system)
RedundancyMirrors, RAID-Z1/2/3RAID1/10 stable; RAID5/6 not recommendedRAID 1, 5, 6, 10
In the Linux kernelNo (OpenZFS module; Ubuntu ships it)YesYes (mdadm)
MemoryUses free RAM as cacheModestModest
Best forNAS, storage servers, parity arraysDesktops, single disks, mirrorsSimple servers with ext4 or XFS

ZFS

ZFS combines the volume manager and the file system. Every block is checksummed; when a read fails its checksum, ZFS fetches the good copy from the mirror or rebuilds it from parity and rewrites the bad one. A regular scrub reads everything and repairs quietly decayed blocks before you need them. Snapshots are instant and cost nothing until data changes, and zfs send streams them to another machine.

Its licence keeps it out of the mainline Linux kernel, so it is installed as the OpenZFS module (Ubuntu ships it ready to use). Plan the layout before you start: a RAID-Z group can be widened one disk at a time only since OpenZFS 2.3.

# A two-drive mirror, then a monthly scrub to find and fix bad blocks
sudo zpool create tank mirror /dev/nvme0n1 /dev/nvme1n1
sudo zpool scrub tank
zpool status tank

Btrfs

Btrfs has the same core ideas, checksums, copy-on-write, snapshots and subvolumes, and is part of the mainline kernel, which makes it the default on Fedora Workstation and openSUSE. It is excellent on a single disk or in RAID1 and RAID10. Its RAID5 and RAID6 modes still carry warnings in its own documentation, so do not use them for data you care about.

Plain RAID

Linux software RAID (mdadm) or a hardware controller keeps several drives in step at the block level, with an ordinary file system such as ext4 or XFS on top. It survives a failed drive and is understood by every tool and rescue system. What it cannot do is notice corruption: if two mirrored copies differ, RAID has no checksum to say which is right. That is acceptable on a server whose important data is backed up elsewhere.

cat /proc/mdstat          # array health at a glance
sudo mdadm --detail /dev/md0

On a new dedicated server, first checks on a new dedicated server shows how to see what layout you were given and test the drives.

Which to Choose

  • A NAS or storage server with several drives: ZFS, with RAID-Z2 for larger arrays.
  • A desktop, laptop or single-disk server where snapshots help: Btrfs.
  • A two-drive server where simplicity matters most: an mdadm mirror with ext4 or XFS, or a ZFS mirror if you want checksums.

Whatever you pick, keep a backup somewhere the server cannot delete it. The 3-2-1 backup rule explains how.

OpenZFS, Fedora and openSUSE are trademarks of their respective owners. Virteche is not affiliated with or endorsed by them. Details about their products come from their public documentation as of the date at the top of this guide.

Common Questions

  • Is RAID a backup?

    No. RAID, ZFS mirrors and Btrfs RAID1 protect against a failed drive. They copy a deletion, a ransomware encryption or a bad update to every drive instantly. Snapshots help against mistakes, but a backup is a copy on separate storage that the server cannot overwrite.

  • Does ZFS need ECC memory?

    It is recommended, not required. ECC protects data while it is in memory, which helps any file system; ZFS's checksums protect it on disk. ZFS without ECC is still safer than a file system without checksums.

  • Is Btrfs RAID5 safe to use?

    Btrfs's own documentation still warns that its RAID5 and RAID6 modes have known problems, including the write hole after a power loss. Its RAID1 and RAID10 modes are considered stable. For parity RAID, use ZFS RAID-Z or mdadm.

  • How much RAM does ZFS need?

    Less than its reputation suggests. ZFS uses free memory as a read cache (the ARC) and gives it back under pressure. Large amounts of RAM per terabyte are only needed if you turn on deduplication.

Every dedicated server has two NVMe drives and is set up by our team before it is handed over.

See dedicated servers

Keep Reading

All guides