How to Migrate a ZFS Pool Between Systems: A Step-by-Step Guide for Data Transfer and Disk Replacement


2 views

ZFS is designed with excellent portability features, allowing pools to be moved between systems with compatible ZFS versions. When you export a pool properly, ZFS stores all necessary metadata including disk UUIDs, vdev layout, and pool configuration, making it recognizable on other Linux systems.

On your current EasyStore NAS, first check your pool status:

zpool status
zpool list

Export the pool properly to preserve metadata:

sudo zpool export your_pool_name

After exporting:

  • Power down the system
  • Label disks physically to maintain order (important for RAIDZ)
  • Transfer disks to the new computer

On the new Ubuntu machine with ZFS installed:

sudo zpool import
sudo zpool import your_pool_name

If you encounter issues, try these debugging commands:

sudo zpool import -d /dev/disk/by-id
sudo zdb -e your_pool_name

Case 1: Different ZFS versions

sudo zpool upgrade your_pool_name

Case 2: Missing disk devices

ls -l /dev/disk/by-id
sudo zpool import -d /dev/disk/by-id your_pool_name
  • Always perform a dry-run first: sudo zpool import -n
  • Verify data integrity after import: sudo zpool scrub your_pool_name
  • Consider taking a ZFS snapshot before migration

Here's a sample bash script for safe migration:

#!/bin/bash
POOL_NAME="your_pool_name"
DEST_DIR="/mnt/new_pool"

# Export pool safely
zpool export $POOL_NAME || { echo "Export failed"; exit 1; }

# On destination system
zpool import -d /dev/disk/by-id -f $POOL_NAME || \
zpool import -f $POOL_NAME

# Verify import
zpool status $POOL_NAME && \
echo "Migration successful" || \
echo "Migration failed"

ZFS pools are designed to be portable across systems running compatible ZFS implementations. When you export a pool (zpool export) and physically move the disks to another machine, ZFS should recognize the pool during import (zpool import). However, there are critical considerations:

# On source system:
sudo zpool export tank

# On destination system:
sudo zpool import tank

Modern Linux systems using udev/devfs will typically recognize disks by their physical paths (e.g., /dev/sd*). For reliable cross-system imports, consider:

# Use disk IDs instead of device paths
sudo zpool create -m /mnt/tank tank mirror /dev/disk/by-id/ata-ST3000DM001-1ER166_Z5008CYK /dev/disk/by-id/ata-ST3000DM001-1ER166_Z5008CYJ

# Alternative: Use GPT labels
sudo zpool import -d /dev/disk/by-partlabel tank

For your EasyStore NAS scenario, here's a tested workflow:

  1. On temporary system:
    sudo zpool create -m /mnt/newpool newpool raidz1 /dev/sdb /dev/sdc /dev/sdd
    sudo rsync -avzP /mnt/oldpool/ /mnt/newpool/
    sudo zpool export newpool
    
  2. On EasyStore NAS:
    sudo zpool import newpool
    sudo zfs set mountpoint=/mnt/data newpool
    

If systems run different ZFS implementations (e.g., ZoL vs OpenZFS), use:

# Check version compatibility
sudo zpool upgrade -v

# Force import (use with caution)
sudo zpool import -f -o readonly=on tank

If the pool isn't recognized:

# Scan for available pools
sudo zpool import

# Locate missing devices
sudo zpool import -d /dev/disk/by-id -D

# Recover from cache file
sudo zpool import -c /etc/zfs/zpool.cache tank

Remember to test pool integrity after migration:

sudo zpool scrub tank
sudo zpool status -v