Hyper-V P2V using Disk2vhd

Migration of physical server to Hyper-V VM – P2V using Disk2vhd

If you prefer video over written format the corresponding video for this write-up can be viewed below:

P2V (or Physical to Virtual) is a process wherein you can take an existing physical server and convert it to a format that can then be run on a virtualized platform, such as Hyper-V.  There are a variety of methods and tools that can be used to accomplish this and this article will focus on one of those: P2V using Disk2vhd

P2V using Disk2vhd

Disk2vhd is a Sysinternals tool By Mark Russinovich.  It is an extremely easy to use utility that creates VHD (Virtual Hard Disk – Microsoft’s Virtual Machine disk format) by leveraging Windows’ Volume Snapshot capability to create consistent point-in-time snapshots of the volumes you want to include in a conversion.

This can be performed while the physical server is online and running so this method of conversion can be accomplished with relatively little or even no downtime.

High Level Overview of P2V using Disk2vhd

  1. Download the Disk2vhd utility
  2. Run Disk2vhd on the physical server you wish to convert to a Hyper-V VM
  3. Create a new VM on the Hyper-V hyp and attach the .vhd(s)/.vhdx(s) created by the Disk2vhd utility
  4. Start the new VM (with no vSwitch) and verify everything is operating as expected
  5. Remove any unwanted devices from device manager that are remnants from the physical device.
  6. Shut down physical server
  7. Associate VM NIC with appropriate vSwitch and configure IP information

Step by step of P2V using Disk2vhd

1. Download the Disk2vhd utility

2. Run Disk2vhd on the physical server you wish to convert to a Hyper-V VM

Disk2vhd is an extremely simple and straightforward utility to use.  Simply launch it and it identifies all the associated drives on your physical server.  Disk2vhd will create a seperate .vhd/.vhdx for each disk.  (Note: it will not create a separate .vhd/.vhdx for each drive letter as those volumes may be on the same disk.  A separate .vhd/.vhdx will only be created for each disk.)

Disk2vhd supports saving your new .vhd/.vhdx file(s) to a network share.  So, you can send them right to the Hyper-V storage location if you have the appropriate access configured.

Note: You must select the System Reserved drive for the VHD to be bootable

Disk2vhd - Sysinternals - Multiple drives
Disk2vhd – Sysinternals

In the below example since each volume is part of the same physical drive, Disk2vhd will create only one .vhd/.vhdx.

Disk Management - Multiple Volumes on one physical disk
Disk Management – Multiple Volumes on one physical disk

3. Create a new VM and attach the newly created .vhd/.vhdx(s)

Hyper-V Manager - New Virtual Machine
Hyper-V Manager – New Virtual Machine

I have experienced mixed results when choosing a Generation type after the P2V process.  In most cases I have found that Generation 1 is required to get the VM started.  I believe this is heavily influenced by the physical hardware properties of the machine you are converting.  Unless you are confident that the VM will run as Generation 2 I would suggest choosing Generation 1.  I have had good success later on converting the Generation 1 to a Generation 2 VM using the Convert-VMGeneration script.

Hyper-V New Virtualization Wizard - Specify Generation
Hyper-V New Virtualization Wizard – Specify Generation

Do not associate the new VM with a Virtual switch yet.  When it turns on you don’t want it to accidentally conflict with your existing physical server which is still running.

Hyper-V New Virtualization Wizard - Configure Networking
Hyper-V New Virtualization Wizard – Configure Networking

Ensure to choose – Use an existing virtual hard disk – and browse to the .vhd/.vhdx file you previously created.

Hyper-V New Virtualization Wizard - Connect Virtual Hard Disk
Hyper-V New Virtualization Wizard – Connect Virtual Hard Disk

Configure the VM (at least for the first startup) to be as close to the specs of the physical server as possible.  These can always be changed later after you get a good first boot.

Hyper-V Manager - VM Settings
Hyper-V Manager – VM Settings

4. Start the new VM and verify everything is operating as expected

The VM should boot, permit log in, and should be identical in every way to its physical counterpart other than any static IP information which was previously configured.

5. Remove any unwanted devices from device manager that are remnants from the physical device.

Open Device Manager – devmgmt.msc – and verify that there are no missing drivers.

You also need to ensure that you remove any persisting hardware devices that have carried over from the physical server.  You will likely need to configure Device Manager to display hidden devices to accomplish this.

Open an administrator command window and run the following:

 set devmgr_show_nonpresent_devices=1 

Then, re-open Device Managerdevmgmt.mscand then click on View – Show Hidden Devices

Anything that is grayed out can likely be removed.

Device Manager - Removing unnecessary hidden hardware devices
Device Manager – Removing unnecessary hidden hardware devices

6. Shut down physical server

As we are about to configure the network properties of the new VM the physical server now needs to be powered down to avoid conflict.

7. Associate VM NIC with appropriate vSwitch and configure IP information

Configure your new VM with the appropriate vSwtich and tag VLAN as required.  Then log in and configure your static IP information on the new NIC as required.

Your physical server is now a Hyper-V Virtual Machine!

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*