How to Migrate a Virtual Machine From OpenVZ to VMware

Introduction

This guide shows you how to migrate from OpenVZ to VMware.

VMware is based on a different type of virtualization compared to OpenVZ, which means that it is not possible to convert a VPS automatically from OpenVZ to VMware. Therefore, you need to transfer the files to the new VMware server manually.

It is important to note that you cannot use the same IP address on the new VMware server. Some legacy applications have hard-coded IP address dependencies and this need to be addressed. Users and passwords, on the other hand, will be moved along.

To complete this guide, technical knowledge is required. If you need help migrating, contact us at support@glesys.se for a consultation and a quote.

Step 1 – Preparations

  • Create a VMware server using the same template with the same specifications as your current OpenVZ server. In general you cannot migrate from bigger kernel versions to smaller ones.
  • Make sure you have at least one good backup of the virtual machine you intend to migrate.

Step 2 – Upgrade your servers

Upgrade both of your servers with the latest packages and install rsync as the tool for synchronizing files and libraries between your servers.

apt-get update && apt-get install rsync && apt-get dist-upgrade -y
reboot

Step 3 – Copy files from the old server to the new

Log in as root on your OpenVZ server from where we’ll run rsync. Before proceeding, keep in mind that you need to shut down all applications and services that write to disk, for example: Apache, MariaDB and MySQL. Also make sure to pause any cronjobs running.

Note! Replace $IP below with the IP address of the target server (KVM) when you’re running the rsync syntax to copy the files:

rsync -avz --numeric-ids --delete --exclude /run --exclude /lib/udev --exclude /etc/udev --exclude /lib/modules/ --exclude /aquota.group --exclude /aquota.user --exclude /boot/ --exclude /dev/ --exclude /proc/ --exclude /etc/network/interfaces --exclude /sys/ --exclude /etc/fstab / $IP:/

Step 4 – Install kernel, grub and system management tools

Now the new server has all the data it needs from the OpenVZ server. However, the Debian or Ubuntu package database is also synchronized which is a problem. To fix it we need to reinstall grub.

Log in as root user and run:

Debian

apt-get install linux-image-amd64 linux-headers-amd64 busybox grub-pc acpid acpi-support-base open-vm-tools

Ubuntu

apt-get install linux-image-generic linux-headers-generic busybox grub-pc acpid acpi-support open-vm-tools

You will be asked where to install the boot loader. Choose /dev/sda.

GRUB install devices:
[*] /dev/sda (21474 MB; ???)

Enable the console (if it’s not already):

systemctl enable getty@tty1.service

Reboot the server:

reboot

Now you are able to log in to the new server (VMware) with the same credentials as you used on the old server (OpenVZ). Keep in mind that you have a new IP address.

Step 5 – Tips

If you have been using DNS or a load balancer for the OpenVZ server it is now time to redirect it to the VMware server.

It’s not recommended to permit root login with password over SSH. We recommend to disable the possibility to log in with password in the SSHd server and only allow SSH keys.

Note! Make sure you can log in with your SSH key before taking this action.

sudo sed -i 's/^PermitRootLogin yes/PermitRootLogin prohibit-password/g' /etc/ssh/sshd_config

sudo systemctl restart sshd

If you don't wish to keep your OpenVZ server after migration, you have to delete it in the control panel after shutdown – otherwise you will still be billed for it.

Need assistance?

If you need help migrating, contact us at support@glesys.se for a consultation and a quote.

Hittar du inte det du söker?

Kontakta oss gärna för mer information. Vi hjälper dig att komma fram till den bästa lösningen för dina behov.

Skicka e-post Ring 0200-23 88 00