So, we have a bunch of project VMs, half of them paravirtualised and the other half fully virtualised. They need to be migrated to a new physical host machine which has a different Xen kernel than the previous system. That means there’s incompatibility between the PVMs kernel and the physical hosts’s kernel. Moreover, the VMs must be migrated with the prospect of being supported in a KVM environment as well. Easier way to handle this? Copy the kernel and the libraries from the HVMs to the PVMs (assuming the OS and configuration are pretty much similar).
1) Use ‘kpartx’ to map the partitions of the disk image or of the logical volume to a loop device.
kpartx -a hvm.img kpartx -a pvm.img
2) Mount the required partitions of both systems under two different directories on the same physical host that need to be migrated (you’ll need to have copied already the disk image or the partition)
mount /dev/mapper/loopHVM /mnt/hvm mount /dev/mapper/loopPVM /mnt/pvm
3) Synchronise the /boot and /lib/modules
rsync -avz /mnt/hvm/ /mnt/pvm/boot/ rsync -avz /mnt/hvm/lib/modules/ /mnt/pvm/lib/modules/
And that should be it. The same host should be also bootable in KVM.
NOTE: Copying over a physical partition, be it logical volume or not, could be easier with the following pipe:
dd if=/path/partition | ssh -c blowfish root@host "dd of=/path/partition"