Migrating a ZFS pool to new Proxmox Server

Migrating a ZFS pool to new Proxmox Server

I recently moved from a new Proxmox server and had to move a ZFS pool.

It can feel pretty scary because you're moving data accross a new machine after all, but it is in fact incredibly easy. Here I will just share the few steps needed to achieve this seemlessly.

Step 1: Prepare the ZFS pool on the original machine

If you could not perform this step because you don't have access to the original server anymore (corrupted?); you will still be able to import your pool. The risk is that some of the last modified data will be lost. Let's say you have a pool named "data". Export it from the host using:

zpool export data

You can force the export if you get a "device busy" error with:

zpool export -f data

Just know that this may lead to loss of the last written data. There should be a valid reason why the pool cannot be exported. You can wait a few seconds and try again.

Once this is done, simply power off the machine – e.g.

shutdown now

Step 2: Import the pool in the new machine

Now physically move the disks of the zpool into the new server and boot it up.

You can then simply do:

zpool import

Which should locate your pool:

  pool: data
    id: 5847392016429581847
 state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:
        NAME                                 STATE
        data                                 ONLINE
          mirror-0                           ONLINE
            ata-ST14000VN08-2PX103_WWZ41VWX  ONLINE
            ata-ST14000VN08-2PX103_WWZ52YZA  ONLINE

You can then simply:

zpool import data

Step 3: Register it with Proxmox

You should now see from the shell your pool, but it will not appear in Proxmox GUI under ZFS and the pool will not be automatically brought up on the next system restart.

There is one last step to do in order to have it permanently setup with your new server:

pvesm add zfspool data --pool data

pvesm is the Proxmox VE Storage Manager CLI tool. It's a CLI API to Proxmox. After this step is complete, your zfs pool would have been successfully migrated and you should see it in the Proxmox web interface.