Copy proxmox linked clone to new server

These instructions are for Proxmox, but the general principle applies for all qemu linked clones.

All steps in the shell prompt need to performed as root.

Existing server setup – change according to your VMIDs

Base template :
VMID 101 and location is /var/lib/vz/images/101 (filename is base-101-disk-1.qcow2)
VMID 101 disk type is Virtio/Network is Virtio, format is qcow2
Linked Clone :
VMID 102 and location is /var/lib/vz/images/102 (filename is vm-102-disk-1.qcow2), format is qcow2

Shut down the clone. Copy both files to the new server, to /var/lib/vz/ (Since this is most likely on a different volume from the rest of the system, copying the files here will make it faster to move them to the final locations). You can now restart the clone.

New server – Change according to your desired VMIDs

Steps to be completed via the Proxmox GUI

1) Create a VM with virtio disk and network and mark it as a template. Do not waste time installing an OS. Let’s presume this VMID is 110, so the template location will be /var/lib/vz/images/110 and the filename will be base-110-disk-1.qcow2
2) Create a VM as a linked clone. Assume this to be VMID 111, so the VM location will be /var/lib/vz/images/111 and the filename will be vm-111-disk-1.qcow2. Do not start the linked clone.

Steps to be completed via the shell prompt

For the template:

cd /var/lib/vz/images/110
# Proxmox marks the base template as immutable (which it should!), so this needs to be done 
chattr -i base-110-disk-1.qcow2
rm base-110-disk-1.qcow2
mv /var/lib/vz/base-101-disk-1.qcow2 .
mv  base-101-disk-1.qcow2 base-110-disk-1.qcow2
# make the template immutable again
chattr +i base-110-disk-1.qcow2

For the linked clone:

cd /var/lib/vz/images/111
rm vm-111-disk-1.qcow2
mv /var/lib/vz/vm-102-disk-1.qcow2 .
mv vm-102-disk-1.qcow2 vm-111-disk-1.qcow2
qemu-img info vm-111-disk-1.qcow2
#You will see that the base file points to old location. This needs to be changed by rebasing the image
qemu-img rebase -u -b ../110/base-110-disk-1.qcow2  vm-111-disk-1.qcow2

You can go back to the proxmox interface and start the clone. Fingers crossed. It should work as it did on the old server.