Physical machine to Hyper v virtual machine

 Migrating Physical machine to virtual machine in Hyper V

 

Install / Run Disk2vhd:

 

Disk2vhd is a utility that creates VHD (Virtual Hard Disk - Microsoft's Virtual Machine disk format) versions of physical disks for use in Microsoft Virtual PC or Microsoft Hyper-V virtual machines (VMs). Open Disk2vhd to generate vhdx files from local hard drive.

 

Download it from the below link.

https://docs.microsoft.com/en-us/sysinternals/downloads/disk2vhd

Install or run this file from the system that is to be converted to virtual machine and select the relevant volumes to be converted to vhdx files.

 





Fig 1. Disk2vhd console with volumes to include and vhd save location

Make sure the checkboxes “Use Vhdx” & “Use Volume Shadow Copy “is selected.


Fig 2 vhdx creation process


Fig 3. File format

This generates a vhdk file that contains the hyper v disk format. Make sure all the volumes are selected in conjunction with operating system volume.

Copy over the file to an HDD to be transferred over to Hyper V host:

Connect an HDD with sufficient free space and copy the generated vhdk file(s) to the disk.

 


Fig 4. Copying vhdx

 

The generated virtual disk format is usually in GPT partition and for the virtual machine to boot up, the disk must be converted to MBR format.

Install AOMEI partition assistant:

A complete disk converter that can easily convert the disk between MBR and GPT, convert dynamic disk to basic disk or vice versa, and convert file system between NTFS to FAT32 without data loss.

Microsoft inbuilt diskpart cannot convert GPT to MBR disk and hence the tool is preferred for conversion. Download the software from the below link.

https://www.aomeitech.com/aomei-partition-assistant.html

 Mount the image to the hyper v host.


Open AOMEI partition manager, Click yes when prompted to load new virtual disk.

 


Fig 5. Mount the vhdx file in the system and load the disk in AOMEI partition manager.

Once the user could see the disk in partition manager, the disk is to be converted to MBR disk to make a bootable partition in vm.


 

Fig 6. Conversion of disk to MBR

 

Select the disk by looking at the partition manager and convert to MBR disk


Fig 7. Error stating requirement of conversion not met.

 

 

Some disks cannot meet the requirement from conversion from GPT to MBR.

Delete the unwanted partitions

Delete the partitions that you did not select while creating vhdk files towards the end. Select Apply at the end of the operation before proceeding further.


Fig 8. Apply the changes before proceeding on the menu bar

 

Now try converting the GPT disk to MBR and it should work.

 


Fig 9. GPT to MBR conversion progress

 

Since partitions at the disk are deleted, create another VHDX file for rest of the partitions from the physical machine to be converted.

After disk is converted to MBR, delete the EFI partition (quickly with files retained) and detach the disk from this pc console.



Fig.10 Eject the disk once conversion is over

 

Create new virtual machine in Hyper V console



Fig 11 Create new virtual machine in Hyper V host to run the p2v machine.

 

Select the destination folder and generation 1 .

 



 

IIn connect virtual hard disk page, select the “” Use an existing virtual disk and click finish. Boot the machine and one can observe a blinking cursor that indicates machine not booting.


Fig 13 Windows 2019 booting

 

 

Insert windows 2019 ISO image in the dvd drive for troubleshooting and load the installation media.

(Media à DVD drive à insert (Windows 2019 iso image))

Select Repair your computer à troubleshootingà  command prompt.

Activate the primary partition using disk part

 

Ø  diskpart

Ø  list disk

Ø  select disk 0 (select appropriate disk)

Ø  list partition

(make sure the EFI partitions are not here or else delete it by selecting the partition and delete partition command)

Ø  Select partition 1 (Select the partition with the OS file, in my case its partition 1)

Ø  Active (activate the partition)

 


Fig 14 Disk part commands

Reboot the machine and get to command prompt again in DVD iso.

Enter the following commands to fix the boot partition.

Ø  bootrec /fixmgr

Ø  bootrec /fixboot  (if it creates “access is denied” error ignore and enter below command.)

Ø  bcdboot c:\windows /l en-us /s c: /f all  (here the second drive letter changes depending on your configuration)


Fig 15 bcdboot

And finally reboot the machine to see if this boots up.



Fig 16. Windows 2019 booting up.

The OS loads up successfully. Have a check on networking, and disk availability once the os boots up.


 

 

 


Comments