How to Convert ZFS RAID-Z1 to RAID-Z2/RAID-Z3 in FreeNAS Without Data Loss


3 views

When working with ZFS on FreeNAS (now TrueNAS), one common administrative challenge is converting existing storage pools between RAID-Z levels. The fundamental limitation is that ZFS doesn't support in-place conversion of RAID-Z topologies.

Unlike traditional RAID systems where you might add a disk to increase parity, ZFS requires more strategic planning. There are three practical approaches:

# Current pool structure example
zpool status mypool
  pool: mypool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        mypool      ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            ada0    ONLINE       0     0     0
            ada1    ONLINE       0     0     0
            ada2    ONLINE       0     0     0

This is the most reliable method:

  1. Create a new pool with desired RAID-Z level
  2. Use ZFS send/receive to transfer data
# Create new pool with RAID-Z2
zpool create newpool raidz2 ada3 ada4 ada5 ada6

# Take snapshot of original dataset
zfs snapshot mypool/data@migrate

# Send/receive the data
zfs send mypool/data@migrate | zfs receive newpool/data

If you can't create a new pool, consider adding higher-parity VDEVs:

# Add RAID-Z2 VDEV to existing pool
zpool add mypool raidz2 ada3 ada4 ada5 ada6

# Then gradually move data to the new VDEV
zfs set primarycache=metadata mypool/data
rsync -av /mnt/mypool/data/ /mnt/mypool/data_new/
zfs rename mypool/data mypool/data_old
zfs rename mypool/data_new mypool/data
  • Always have complete backups before attempting pool modifications
  • Monitor disk health during large data transfers
  • Consider performance impacts during migration
  • Verify checksums after data transfer completes

The upcoming OpenZFS 3.0 may include RAID-Z expansion capabilities. Early testing shows:

# Hypothetical future syntax (not currently available)
zpool expand mypool raidz1=raidz2 ada0 ada1 ada2 ada3

When working with ZFS storage on FreeNAS (now TrueNAS), administrators often start with RAID-Z1 configurations for basic parity protection. However, as storage requirements grow and data importance increases, upgrading to higher parity levels (RAID-Z2 or RAID-Z3) becomes desirable for enhanced fault tolerance.

ZFS doesn't support in-place conversion between RAID-Z levels due to its copy-on-write architecture. The only supported method involves creating a new pool with the desired RAID level and migrating data. Here's why this limitation exists:


# Current pool layout (example)
NAME        STATE     READ WRITE CKSUM
tank        ONLINE       0     0     0
  raidz1-0  ONLINE       0     0     0
    ada0    ONLINE       0     0     0
    ada1    ONLINE       0     0     0
    ada2    ONLINE       0     0     0

Here are three approaches to achieve the parity upgrade:

Method 1: Using Temporary Storage


# Step 1: Create backup
zfs snapshot -r tank@migration
zfs send -R tank@migration > tank_backup.zfs

# Step 2: Destroy and recreate pool
zpool destroy tank
zpool create tank raidz2 ada0 ada1 ada2 ada3

# Step 3: Restore data
zfs receive -F tank < tank_backup.zfs

Method 2: Disk Replacement Technique

For systems with available disk slots:


# Add new disks as mirrors first
zpool attach tank ada0 ada4
zpool attach tank ada1 ada5
# Wait for resilvering...

# Then convert to RAID-Z2
zpool detach tank ada0
zpool detach tank ada1
zpool add tank raidz2 ada4 ada5 ada2 ada3

Method 3: Using ZFS Send/Receive

For large pools where downtime must be minimized:


# On new pool (tank_new):
zfs create tank_new/migrate
zfs set readonly=on tank_new/migrate

# On original pool:
zfs send -R tank@snapshot | zfs receive -F tank_new/migrate

# After verification:
zpool export tank
zpool import -R /mnt tank_new tank

Before proceeding with any migration:

  • Verify you have complete backups
  • Check SMART status of all disks
  • Ensure adequate power redundancy
  • Plan for extended resilvering times

If immediate migration isn't feasible, consider enhancing your existing setup:


zpool add tank cache ada6  # Add SSD as cache
zfs set primarycache=all tank
zfs set secondarycache=all tank