ZFS offers powerful software RAID features built into its storage pool (zpool) layer. Unlike traditional software RAID tools like mdadm, ZFS RAID is tightly integrated with the filesystem, offering data integrity, easier management, and better recovery options.
Here's a breakdown of the software RAID options ZFS supports:
Description: Data is duplicated across two or more disks. Best for redundancy and read performance.
sudo zpool create mymirror mirror /dev/sdX /dev/sdY
mirror /dev/sdX /dev/sdY /dev/sdZ) – ZFS will mirror across all.Description: Uses parity to recover from a single disk failure.
sudo zpool create myraid raidz /dev/sd{b,c,d}
Description: Tolerates two disk failures.
sudo zpool create myraid2 raidz2 /dev/sd{b,c,d,e,f}
Description: Tolerates three disk failures.
sudo zpool create myraid3 raidz3 /dev/sd{b,c,d,e,f,g}
| Mirror | 2 | 1 (or N-1) | 50% (if 2 disks) | Fast reads, writes may scale linearly |
| RAID-Z | 3 | 1 | N - 1 | Efficient, safe for moderate setups |
| RAID-Z2 | 4 | 2 | N - 2 | High safety, good for medium/large arrays |
| RAID-Z3 | 5 | 3 | N - 3 | Max safety, best for critical data |
-o ashift=12
Sets the sector size to 2^12 (4096 bytes). Best for modern disks (especially SSDs). You cannot change this later.
ZFS can keep extra disks idle, ready to take over when another fails:
sudo zpool add mypool spare /dev/sdX
ZFS will automatically replace a failed disk with a spare.
sudo zpool create badpool /dev/sdX /dev/sdY
Never use multiple disks in a single pool without mirroring or RAID-Z.
—
sudo zpool status
sudo zpool offline mypool /dev/sdX
sudo zpool replace mypool /dev/sdX /dev/sdY
sudo zpool status
ZFS will rebuild the data on the new disk automatically.
sudo zpool create -o ashift=12 \
-O compression=lz4 \
-O atime=off \
testpool raidz /dev/sd{b,c,d}
sudo zfs create testpool/files
echo "Hello ZFS RAID-Z" | sudo tee /testpool/files/test.txt
sudo zfs snapshot testpool/files@first
Then simulate a failure by detaching or offlining a disk and using zpool status, replace, and resilver.
by: ▖ ▘▖▖ ▌ ▌▌▛▘▌▙▌ ▙▖▙▌▙▖▌ ▌ edited: June 2025