I had a xen server (centos 5 base) that was running a set of Linux VM's. Said server has perished in a ball of fire. While it might be possible to save it at some point, in the meantime I really need to get those VM's back online...Problem is, my other VM host is KVM based. I have backups of all the xen config/xml files, as well as the .img file, moved over to the KVM system...

But I'm not sure how to convert the xen VM to a KVM, as all the virt-v2v guides reference pulling over ssh from an active hypervisor.

I'm also not sure what to do about the xen kernel currently running on the system...Any advice?


Found my solution.

First I needed to mount the drive image based on the offset, bind mount /dev, chroot to the mount and download a non-xen kernel:

  • To get the partition info of the drive

    fdisk -l /images/server1.img
  • Mount the drive, the offset is the Unit size listed in fdisk Multiplied by the start point listed in fdisk

    mount -t auto -o loop,offset=<offset goes here> /images/server1.img /mnt/server1
  • Mount the boot partition. Same rules apply

    mount -t auto -o loop,offset=<offset goes here> /images/server1.img /mnt/server1/boot
  • Bind mount /dev (/dev/urandom is required by yum to download things)

    mount --bind /dev/ /mnt/server1/dev
  • chroot to the drive

    chroot /mnt/server1
  • install kernel, and exit chroot

    yum -y install kernel
  • umount everything

    umount /mnt/server1/dev
    umount /mnt/server1/boot
    umount /mnt/server1
  • Install virt-v2v, and use it to convert, targeting the "disk" type

    yum -y install virt-v2v
    virt-v2v -i disk /images/server1.img -o local -os /images/
  • start new vm

    virsh create /images/server1.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.