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
and add these lines
# Run gettys in standard run levels
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.
add these lines to exclude.txt, you may customize it to your needs
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
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.