When moving a KVM image to another server, it’s a pretty simple process. If you’re using SolusVM or Virtualizor, it makes it even easier. However, if you have a VM node which hosts openVZ containers and need to move them to a new node with different virtualization, QEMU/KVM in this case, it makes things a little more difficult.
The main different between KVM and openVZ is the level of virtualization. OpenVZ is an OS level virtualization which means the hosts’ kernel is shared with guest containers inside it, you can’t use your own kernel.
KVM is very different. It’s a full virtualization. The whole OS and its kernel is virtualized so you can even install an OS with its own kernel in it, like installing Windows VM inside a linux host.
So let’s get on with this tutorial now that we have a little background. Please proceed at your own risk!
– Converting OpenVZ to KVM box
Let’s start the moving process.
1. The first step before start moving the box is installing a KVM box with the exact same OS as the openVZ container, preferably same point revision too (You will want to run yum update on both VM’s to make sure)
2. SSH into both VMs.
3. In the KVM box, or openVZ box, install mingetty. I’m using CentOS 6.2 so I use yum to install mingetty
yum install mingetty
4. Edit /etc/inittab in the VM installed with mingetty
vi /etc/inittab
and add these lines
# Run gettys in standard run levels
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
This will enable the machine to actually get a logon prompt.
5. Install rsync on both VMs
yum install rsync
6. From the openVZ box, make a text file containing files to exclude. This will preserve settings in KVM box to make sure the VM is bootable.
nano /root/exclude.txt
add these lines to exclude.txt, you may customize it to your needs
/boot
/proc
/sys
/tmp
/dev
/var/lock
/etc/fstab
/etc/mtab
/etc/resolv.conf
/etc/conf.d/net
/etc/network/interfaces
/etc/networks
/etc/sysconfig/network*
/etc/sysconfig/hwconf
/etc/sysconfig/ip6tables-config
/etc/sysconfig/kernel
/etc/hostname
/etc/HOSTNAME
/etc/hosts
/etc/modprobe*
/etc/modules
/net
/lib/modules
/etc/rc.conf
/usr/share/nova-agent*
/usr/sbin/nova-agent*
/etc/init.d/nova-agent*
/etc/ips
/etc/ipaddrpool
/etc/ips.dnsmaster
/etc/resolv.conf
/etc/sysconfig/network-scripts/ifcfg-eth0
7. Now we can start to sync the OpenVZ box to the KVM box. In the openVZ box, type:
rsync –exclude-from=”/root/exclude.txt” –delete –numeric-ids -avpogtStlHz -e “ssh -p ” / root@
That’s all, to make sure everything’s working, reboot the KVM box when the rsync process has completed. Once your new KVM box is up, you will have to go in there and make the IP changes to cPAnel/WHM, shoutcast, zPanel, or whichever other control panel you’re using.
https://blog.webhostpython.com/2015/11/25/how-to-convertmigrate-openvz-vps-to-xenkvm/