How to migrate Windows Virtual Servers from Hyper-V to my Cloud.Net cloud?
Cloud.Net, all versions.
Images of Hyper-V virtual servers need to be prepared and converted for running into Cloud.Net KVM-based environment. There are three main steps: source vhd(x) preparation using prepare-vhd.ps1 script, transferring the image to the cloud.net, converting vhd(x) with writing the data to the destination disk.
You will need a .vhd or .vhdx image of the Virtual Machine.
A windows environment. It can be a Windows Server where Hyper-V VMs are running on or any other host with Windows based desktop or server operating system. The newer is better.
A Cloud.Net account.
Downloaded virtio drivers for windows. A stable or latest virtio-win ISO.
Downloaded windows version of GPT fdisk from https://sourceforge.net/projects/gptfdisk/files/gptfdisk/ .
Extract gdisk64.exe and put it to C:\Windows or C:\Windows\Sytem32.
Preparing the source image (Windows environment)
1. Stop the virtual machine which you want to migrate if it is still running. Make a copy of its VHD(x) disk just for case if something goes wrong. You should also move away all data from non-system partitions as all partitions except of the system one will be erased. OnApp supports one partition - one disk configuration so if you need disk D:, E: etc into your virtual machine, you can add them later as separate drives in OnApp environment.
2. Download the script.
3. Open Windows PowerShell with administrator's rights:
4. Mount virtio-win ISO:
5. Execute the downloaded script.
.\prepare-vhd.ps1 -Winver <windows_version> -Image <path_to_image> -Driverpath <path_to_virtio_drivers>
There are three mandatory input parameters:
- -Winver - one of the following: 2k19, 2k16, 2k12r2, 2k12, w10, w8.1, w8.
- -Image - the path to .vhd or .vhdx image
- -Driverpath - the path to mounted or unpacked ISO of virtio drivers.
At the next screen shot you can see an example of the command for windows 2019 vhdx image with mounted virtio-win ISO as drive D:\
The script makes repartitioning inside of the VDH(x), leaves only Windows partition and injects virtio drivers into installed Windows.
After successful completing the script you can proceed to the next step.
Cloud.Net side preparations
1. Create a dummy Windows Virtual Server with desired amount of CPU, RAM. Make sure that the disk has the same size or larger than the disk of the source VM.
2. Attach to the VS a secondary disk with the same size or larger than your source vhd(x).
3. Reboot the VS into Recovery:
4. Transfer the source vhd(x) image to the second VS'es drive via scp. You can use WinSCP or any other software with ability for transferring files over ssh.
Convert vhd(x) with transferring data to the destination disk
1. Open VS'es console or connect to its recovery mode shell via ssh.
2. Locate the primary VS disk.
3. Transfer the data to the disk:
[root@recovery ~]# qemu-img dd -f vhdx -O raw if=/mnt/Win2019.vhdx of=/dev/vda bs=64k
If the recovery image doesn't support dd option use the following command:
[root@recovery ~]# qemu-img convert -f vhdx -O raw /mnt/Win2019.vhdx /dev/vda
/mnt/ is the mountpoint of the secondary drive,
/dev/vda is the primary VS drive.
After completing the
qemu-img command you can reboot the virtual server. The secondary drive is not needed at this stage, you can delete it.
4. Choose Reset Root Password from the dropdown Tools menu (if you wish to set the Administrator's password) and then set IP address, Netmask, Gateway, DNSes for the network interface(s) inside the virtual server.