====== Migrate_Xen_based_VM_(domU)_to_KVM_based_VM ====== Xen VMs do not have bootable disks. I.E. there is typically no grub config to worry about as a Xen kernel is used to boot DomU's. KVM however "typically" allows guest VMs to run unmodified kernels and as a result typically have disks and partitions including a /boot and grub mbr. ====== Method 1 ====== KVM however can boot a Xen (disk based or LVM) VM using a kernel and initrd config. OrigXen: lvcreate -L1G -s -n vmdisksnap /dev/vg0/vm01-disk //Create a LVM Snapshot NewKVM : lvcreate -n deb05-disk --size 3g vg0 //Create a new LV with same size NewKVM : lvcreate -n deb05-swap --size 512M vg0 //Create swap LV as was done on the Xen host originally NewKVM : nc -l -p 7000 | dd of=/dev/vg0/deb05-disk bs=2M //use net cat and dd with bs=2M to speed things up. OrigXen: dd if=/dev/vg0/vmdisksnap bs=2M | nc x.x.x.x 7000 -q 10 //using port 7000 for nc scp initrd.img-2.6.26-2-686-bigmem to new host //scp across original kernel and initrd image. scp vmlinuz-2.6.26-2-686-bigmem to new host cp /etc/libvirt/qemu/deb04.xml /etc/libvirt/qemu/deb05.xml //copy an existing libvirt xml domain. We are going to edit it by hand instead of going virt-install vi /etc/libvirt/qemu/deb05.xml //delete the uuid line. //change the name. Delete the mac address line. //add the jernel and initrd options. //add a cmdline root=/dev/vda and an optional console=ttyS0 allowing you to go virsh console deb05 deb05 196608 196608 1 hvm **/root/vmlinuz-2.6.26-2-686-bigmem** **/root/initrd.img-2.6.26-2-686-bigmem** **root=/dev/vda console=ttyS0** destroy restart restart /usr/bin/kvm ===== Notes ===== Make sure that the kernel specified is contained on the VM disk under /lib/modules/2.6.... otherwise iptables etc. won't work. The above config uses a separate network br0 bridge. See: [[KVM_Setup_on_Debian_Lenny]] For faster dd's see: http://serverfault.com/questions/147935/how-to-determine-the-best-byte-size-for-the-dd-command For LVM snapshots, see: http://tldp.org/HOWTO/LVM-HOWTO/snapshots_backup.html http://arstechnica.com/open-source/news/2004/10/linux-20041013.ars http://sysadminsjourney.com/content/2008/11/29/backup-lamp-stacks-lvm-snapshots On the original Xen host, you can go: lvremove /dev/vg0/vmdisksnap lvscan //shows all LVs Other tidying up to be done is to: vi /etc/fstab and replace in vda and vdb for swap. Update the IP and gateway in /etc/network/interface