Convert or copy images:
Copy RBD Image between Ceph pools (eg rbd_hdd -> rbd_ssd):
# This command copies the source image to the destination image, honouring parent clone references.
# ie: It copies data from the delta.
rbd deep cp rbd_hdd/vm-108-disk-0 rbd_ssd/vm-108-disk-0;
# This command copies the content in to a new independent image.
# ie: It copies data from both the base source and the delta.
rbd cp rbd_hdd/vm-108-disk-0 rbd_ssd/vm-108-disk-0;
# Add something like '--data-pool ec_ssd' to either copy operation to store data in an erasure coded pool.
pico /etc/pve/nodes/kvm7e/qemu-server/108.conf
rbd_hdd -> rbd_ssd
#rbd rm rbd_hdd/vm-108-disk-0
Copy RBD Image to QCoW2, sparse aware:
qemu-img convert -f raw -O qcow2 -t unsafe -T unsafe -cWp rbd:rbd_hdd/vm-119-disk-0 /var/lib/vz/template/iso/vm-119-disk-0.qcow2;
'c' compresses output file, relatively quick and size isn't much off so I wouldn't separately gzip the raw file.
Herewith an example of a newly deployed system:
rbd du rbd_hdd/vm-119-disk-0 4.9 GiB
QCoW2 5.7 GiB
QCoW2 compressed 2.3 GiB
GZip compressed QCoW2 2.1 GiB # not multi-threaded, so can take a significant amount of time
Copy QCoW2 to Ceph RBD Image:
qemu-img convert -f qcow2 -O raw -t unsafe -T unsafe -nWp /var/lib/vz/template/iso/vm-119-disk-0.qcow2.compressed rbd:rbd_hdd/vm-119-disk-0;
Copy RBD Image, uses thin provisioning and skips zeros:
qemu-img convert -f raw -O raw -t unsafe -T unsafe -nWp rbd:rbd_hdd/vm-213-disk-1 rbd:rbd_ssd/vm-213-disk-1_new;
Copy QCoW2 image to new RBD image:
qemu-img convert -f qcow2 -O raw -t unsafe -T unsafe -nWp source.qcow2 rbd:rbd_hdd/vm-999-disk-0
Copy RBD Image to VHD (Microsoft Virtual PC), creates a dynamic VHD which skips zeros:
qemu-img convert -f raw -O vpc -t unsafe -T unsafe -o subformat=dynamic -p -S 512 rbd:rbd_ssd/vm-239-disk-1 images/labournet-cms1-old.vhd;
Copy RBD partition to another RBD partition (sector alignment correction):
qemu-img convert -f raw -O raw -t unsafe -T unsafe -nWp /dev/rbd16p1 /dev/rbd17p1
Copy VMDK to RBD, uses thin provisioning and skips zeros:
rbd create rbd_hdd/onos-tutorial --size 200G;
qemu-img convert -f vmdk -O raw -T unsafe -nWp ./onos-tutorial-1.15.0-disk001.vmdk rbd:rbd_hdd/onos-tutorial;