Skip to main content
RunBook Academy

← All labs in Proxmox VE

Lab · foundation · ~60 min

Set up ZFS mirror with spare and exercise disk replacement

A · Physical hardwareB · Nested virtualisationC · Simulation

Objectives

  • Create a ZFS mirror pool with an attached hot spare
  • Simulate a disk failure and watch the spare activate
  • Replace the failed disk and clear the spare
  • Verify pool health across the lifecycle

Prerequisites

  • Three identical disks (or three virtual disks in nested mode)
  • zfsutils-linux installed
  • Proxmox storage model understood

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

Deliverables

  • · A zpool with mirror topology and an attached spare
  • · Demonstrated automatic resilver from the spare
  • · Replaced disk online and spare detached

Verification status

Executed end to end
not yet run on hardware

The commands and configuration here have been reviewed against the verified software versions, but nobody has run this lab start to finish on a system meeting its prerequisites. Treat the Expected Outcome as the intended result rather than an observed one, and keep the Cleanup section to hand.