Migrate XEN to KVM

Aug 14, 2014
1 min read
May 27, 2023 09:13 EEST

Before you start to migrate xen to KVM, make sure that:

  • Block device will change from xvd? to vd?
    • Change grub config and replace “root=/dev/xvda1 disk=/dev/xvda” by “root=/dev/vda1 disk=/dev/vda”
    • Check fstab
  • serial device will change xvc0 to ttyS0
    • Change grub config and remove console=xvc
    • Edit /etc/inittab and comment line containing xvc0 and insert a line with tty1 instead
    • Edit /etc/securetty and replace xvc0 with ttyS0
  • You system is fully bootable with a boot manager (like grub)
  • You have a full kernel installed

Change modules from:

xenblk xennet

to

virtio_blk virtio_pci virtio_net virtio_ballon

Copy KVM Image and Convert to KVM

Get a list of all XEN VMs:

xe vm-list

Copy one VM via ssh to another host:

xe vm-export uuid=<uuid> filename= | ssh -c blowfish -C <user>@<host> 'dd of=/path/vmname.xva'

Use the following script: http://www.robotics.net/wp-content/uploads/xenmigrate.py

Extract the the file with:

tar xvf vmname.xva

You should have a directory like:

---------- 1 root root   30251 Jan  1  1970 ova.xml
drwxr-xr-x 2 root root 1527808 Feb 24 11:10 Ref:5

Convert it with:

python xenmigrate.py --debug -–convert=Ref\:5 {image}.img

Now you can import the image with:

virt-install --name={image] --cpuset=auto --ram=2048 --network bridge=br123 --disk=/dev/vg/example --vnc --vnclisten=0.0.0.0 --noautoconsole --cdrom=/win2k8.iso