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.
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
<domain type='kvm'>
<name>deb05</name> <memory>196608</memory> <currentMemory>196608</currentMemory> <vcpu>1</vcpu> <os> <type arch='i686' machine='pc'>hvm</type> **<kernel>/root/vmlinuz-2.6.26-2-686-bigmem</kernel>** **<initrd>/root/initrd.img-2.6.26-2-686-bigmem</initrd>** **<cmdline>root=/dev/vda console=ttyS0</cmdline>** <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/kvm</emulator> <disk type='block' device='disk'> <source dev='/dev/vg0/deb05-disk'/> <target dev='vda' bus='virtio'/> </disk> <disk type='block' device='disk'> <source dev='/dev/vg0/deb05-swap'/> <target dev='vdb' bus='virtio'/> </disk> <interface type='bridge'> <source bridge='br0'/> <model type='virtio'/> </interface> <serial type='pty'> <source path='/dev/pts/8'/> <target port='0'/> </serial> <console type='pty' tty='/dev/pts/8'> <source path='/dev/pts/8'/> <target port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/> </devices>
</domain>
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