Migrate Xen guest Centos 5 to KVM guest Centos 6

1. On XEN server centos 5.5

Install the normal kernel in all guests (domU)

# yum install kernel

Set the normal kernel as the default boot kernel on “/etc/grub.conf” file

# nano  /etc/grub.conf

and set “default” variable:


edit /boot/grub/device.map

# nano /boot/grub/device.map

and change /dev/xvda  to /dev/vda

# this device map was generated by anaconda                                     
(hd0)     /dev/vda

add virtio_blk to initrd using mkinitrd    (!!! your kernel version number may be different)

# cd /boot
# mv initrd-2.6.18-308.8.2.el5.img initrd-2.6.18-308.8.2.el5.img.bak
# mkinitrd -f –with=virtio_blk –with=virtio_pci –builtin=xenblk initrd-2.6.18-308.8.2.el5.img   \ 2.6.18-308.8.2.el5

add virtio_blk to “/etc/modprobe.conf” file

# nano /etc/modprobe.conf

should look like

alias scsi_hostadapter virtio_blk

edit “/etc/inittab” file and find the following section

# nano /etc/inittab

and find the following section

# Run gettys in standard runlevels
co:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav
#1:2345:respawn:/sbin/mingetty tty1
#2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6

should look like

# Run gettys in standard runlevels
#co:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

Finally power off all guests (DomU) and never boot it from XEN server


2.- On KVM server centos 6.2

Add a new virtual machine from any KVM GUI (in this post I use virt-manager)


Choose whatever ISO file as the install media (will not actually install anything…)


Set RAM and CPU


Choose a very small harddisk image


and end


By default, the new KVM guest is located in /var/lib/xen/images/new_KVM_guest

Finally copy your Xen harddisk image to replace the newly created one

cp   Xen_hdd.img    /var/lib/libvirt/images/new_KVM_guest.img