OpenVZ to KVM migration process

Recently we had a customer that wanted to migrate a large number of virtual servers to our data center. As a company we utilize KVM so this is what we pushed to our customer as a familiarity with this generally leaves us feeling more comfortable with the ability to manage these servers for our customers. Getting into this I quickly realized there was little to no documentation on migrating CentOS 7 machines from OpenVZ to KVM and the documentation all stopped at CentOS 6. They are entirely different beasts so I am going to go ahead and drop my notes here so I can hopefully help someone else out looking to do the same.

In general it is best to ensure that the KVM OS you are migrating to is fully up to date and that your machine that you are migrating from is as well. It is also extremely important to make sure you are migrating 32Bit to 32Bit or 64 to 64, I made this mistake with one of our customers migrations, luckily none of this results in lost data but rather the time consuming process of starting from scratch.

Most of this process is 100% identical to what you would find when migrating CentOS 6 but with minor tweaks:

  1. Go to server to be migrated and create a new file /root/exclude.txt and insert the following lines:

    As you can see from the comments above this is not entirely CentOS 7 specific and can be tweaked a little bit to work with other operating systems.
  2. From the server that is going to be migrated I recommend starting a screen for your rsync command which will most likely take some time to complete depending on the size of the server being migrated. Once in the screen run the following rsync command:

  3. Once the rsync has been completed there are just a couple last little details that need to be addresses. In my case I had to rename the ethernet device names within the OS so I copied the files over and enabled them with the following commands:

You will also want to make sure you rename the getty target service otherwise you will never get a login prompt after rebooting:

Last but not least you will need to do a quick reinstallation of the kernel just as a precaution:

Note the kernel number specifically and run:


As with most tutorials your  milage may vary and things are bound to change over time. If you find anything that needs updating or changing feel free to let me know and Ill update this overtime.

Leave a Reply

Your email address will not be published. Required fields are marked *