ZFS mirror with hot spare
This lab walks through the most resilient ZFS topology used in Proxmox installations: a mirror vdev with a hot spare that activates automatically on disk failure.
Steps
1. Identify your disks
lsblk
# Identify three disks of equal size; for example /dev/sdb /dev/sdc /dev/sdd
2. Create the pool
zpool create datapool mirror /dev/sdb /dev/sdc spare /dev/sdd
Verify the topology:
zpool status datapool
# Expected output shows:
# datapool
# mirror-0
# sdb
# sdc
# spares
# sdd
3. Add Proxmox storage pointing at the pool
pvesm add zfspool datapool --pool datapool --content images,rootdir
4. Create a test VM on the pool
qm create 900 --name zfs-test --memory 1024 --cores 1 \
--scsi0 datapool:32,iothread=1 --net0 virtio,bridge=vmbr0 \
--ostype l26
qm start 900
Verify the VM is up and the pool reports no errors:
zpool status datapool
5. Simulate disk failure
Mark /dev/sdb as failed (replace with your actual mirror member):
# For a real disk: pull it. For a virtual disk in nested mode:
echo 1 > /sys/block/sdb/device/delete
# Or use zfs to mark it failed:
zpool offline datapool sdb
Watch the spare activate:
zpool status -v datapool
# Expected: sdd now active in mirror-0; sdb shows OFFLINE
6. Replace the failed disk
# Replace sdb with a new disk (physically or virtually)
zpool replace datapool sdb /dev/sde
# Watch the resilver
zpool status -v datapool
# Expected: resilver in progress, then completed; spare released
7. Verify final state
zpool status datapool
# Expected: mirror-0 with new sde, no spares active
Confirm the test VM is still running:
qm status 900
Verification
- The test VM survived the disk failure without interruption
- The spare activated automatically within seconds of failure
- After replacement, the new disk resilvered and the spare returned to standby
- No data loss occurred
Cleanup
qm stop 900 && qm destroy 900
zpool destroy datapool