When working with ZFS storage pools, many administrators encounter the same fundamental limitation when trying to expand existing RAIDZ vdevs. The error message you're seeing:
invalid vdev specification: raidz requires at least 2 devices
reveals a core architectural constraint in ZFS. Let's examine why this occurs and explore practical solutions.
The root issue stems from how ZFS handles vdev types and their minimum requirements:
- RAIDZ1/2/3: Requires minimum of 2+N disks (where N is parity level)
- Mirror: Requires minimum 2 disks
- Stripe: Can be created with single disk
Your attempt to add a single disk to RAIDZ violates these fundamental rules. Here are your actual options:
Option 1: Add as Separate VDEV
The most straightforward approach is adding the new disk as a separate vdev:
zpool add backupz c7t4d0
This creates a single-disk vdev in your pool. While functional, it lacks redundancy.
Option 2: Convert to Mirror (Recommended for Small Pools)
For better redundancy with minimal additional disks:
zpool attach backupz c7t0d0 c7t4d0
This converts your existing disk into a mirrored pair.
Option 3: Full Restructure (Best for Large Pools)
For optimal performance and redundancy:
- Create new pool with desired structure
- Use zfs send/receive to migrate data
- Destroy old pool and rename new one
zpool create newbackup raidz1 c7t0d0 c7t1d0 c7t2d0 c7t3d0 c7t4d0
zfs snapshot -r backupz@migrate
zfs send -R backupz@migrate | zfs receive -F newbackup
zpool destroy backupz
zpool rename newbackup backupz
Each approach has distinct performance characteristics:
Method | Performance Impact | Redundancy |
---|---|---|
Single Disk Add | Variable (depends on access patterns) | None |
Mirror Conversion | Improved read performance | Full (for converted disks) |
Full Restructure | Optimal for RAIDZ | Full |
For repeated operations, consider this bash script template:
#!/bin/bash
# ZFS pool expansion helper
POOL="backupz"
NEWDISK="c7t4d0"
zpool status $POOL > /dev/null || exit 1
echo "Select expansion method:"
echo "1) Add as single disk"
echo "2) Convert to mirror (select existing disk)"
echo -n "Choice [1-2]: "
read choice
case $choice in
1) zpool add $POOL $NEWDISK ;;
2)
echo "Available disks in pool:"
zpool status $POOL | grep ONLINE | grep -v raidz
echo -n "Select disk to mirror: "
read existing
zpool attach $POOL $existing $NEWDISK
;;
*) echo "Invalid choice" ;;
esac
When working with ZFS storage pools, it's crucial to understand that RAIDZ vdevs have specific requirements for device counts. The error message you encountered - "raidz requires at least 2 devices" - reveals a fundamental constraint in ZFS architecture.
# This will fail:
zpool add backupz raidz c7t4d0
invalid vdev specification: raidz requires at least 2 devices
ZFS treats RAIDZ vdevs as atomic units. Unlike traditional RAID systems where you might expand arrays disk-by-disk, ZFS requires you to:
- Add complete vdevs to a pool
- Maintain RAIDZ parity requirements
- Keep vdev structure consistent
Here are your viable options with example commands:
# Option 1: Add the disk as a separate non-redundant vdev
zpool add backupz c7t4d0
# Option 2: Create a new mirrored pair (requires 2 disks)
zpool add backupz mirror c7t4d0 c7t5d0
# Option 3: Backup, recreate pool with larger RAIDZ
zfs send -R backupz@snapshot | zfs receive newbackupz
zpool destroy backupz
zpool create backupz raidz1 c7t0d0 c7t1d0 c7t2d0 c7t3d0 c7t4d0
Each approach has distinct performance characteristics:
Method | Capacity Gain | Performance Impact |
---|---|---|
Single disk | Full disk | No redundancy, slowest option |
Mirror pair | 1 disk capacity | Fast reads, write overhead |
Recreated RAIDZ | Added to parity | Balanced performance |
For frequent pool expansions, consider this bash script:
#!/bin/bash
POOL="backupz"
NEWDISK="c7t4d0"
if [ ! -e "/dev/rdsk/${NEWDISK}" ]; then
echo "Disk ${NEWDISK} not found"
exit 1
fi
# Check if we can add as single disk
read -p "Add as non-redundant disk? (y/n) " choice
if [ "$choice" = "y" ]; then
zpool add ${POOL} ${NEWDISK}
else
echo "Please prepare a second disk for mirroring"
fi