Migrate from QCOW2 to ZFS with snapshots

Bruno Meneguello

New Member
Apr 26, 2019
4
0
1
33
I think it's not possible, but as last resort I need to ask: does anyone know if it's possible to migrate a QCOW2 volume to a ZFS volume while preserving snapshots? Even if this must be done outside PVE environment.
 

LnxBil

Well-Known Member
Feb 21, 2015
3,940
366
83
Germany
does anyone know if it's possible to migrate a QCOW2 volume to a ZFS volume while preserving snapshots?
Yes, I know. You may also like to know the answer, do you :p

There is one catch: the history in the QCOW2 file must be linear, otherwise it does not work properly. You also have to keep in mind that you cannot switch between snapshots in ZFS as you can in QCOW2, therefore QCOW2's snapshots are more capable than then ZFS ones with respect to virtualisation.

Idea is like this:
- go to the oldest snapshot in your QCOW2, mount it via qemu-nbd
- copy the block device to your ZFS zvol, dd is fine as a test (*)
- snapshot your ZFS
- unmount your QCOW2 and go to the next snapshot

I hope that helps and gives you enough to create a working example.

(*) You should write your own block-based copy program that omits already present blocks from overwriting, because this is a new write on ZFS and needs space. If you only copy blocks that are different, you can have a 'copy-on-write' kinda snapshot that really only holds changed data.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!