Using Disk2VHD for Hyper-V P2V (Physical to Virtual) Conversions

Using Disk2VHD for Hyper-V P2V (Physical to Virtual) Conversions

Bringing a physical operating environment into Hyper-V can be a challenging task. It is recommended that you use some application-level migration rather than trying to convert a physical operating system installation directly. However, some systems do survive the transition well. One tool that can be used in conversion operations is Sysinternal’s Disk2VHD.

What is Disk2VHD?

Disk2VHD is a software solution provided by Sysinternals. It reads the boot information, partition information, and data regions of a physical hard drive and produces a corresponding VHD or VHDX file. It is very important to understand that this is not a true physical-to-virtual conversion. The operating system is not prepared to run inside a virtual environment, nor is any cleanup work done on the source system to improve the odds of a successful migration.

Microsoft Virtual Machine Converter 3.0

Before using this Disk2VHD to attempt a P2V, you might try Microsoft’s Virtual Machine Converter. It has been expanded to include P2V capability. The tool is provided free-of-charge. Visit the TechNet article for more information. The first link on that page will take you to the download.

Downloading and Installing Disk2VHD for Hyper-V P2V

Sysinternals (now owned by Microsoft) offers this tool as a free download from TechNet. Please read their overview and warnings. There is no actual “installation” of this product. Simply extract the “disk2vhd.exe” file from the ZIP archive and place it on the system whose drives you wish to convert. You can also extract the “Disk2vhd.chm” file; this is the software’s help manual.

Jeffery Hicks has also written a PowerShell script that will retrieve and update the entire Sysinternals catalog.

Pre-Flight Checks and Procedures

It’s a hard fact that physical to virtual conversions are fraught with peril. The older the operating system, the greater the risk. A few things that you should do to prepare:

  • Perform a complete backup to a safe location.
  • Verify that there aren’t any problems with the system. Check event logs, etc. Run CHKDSK.
  • Remove any unnecessary software and drivers, but do not make any changes to the system’s vital configuration that cannot be easily redone. If the P2V fails, you don’t want to be left with an unusable source system. RAID drivers are a common paint point but removing them will render your system unusable.
  • Optional: Remove the system from the domain. This will avoid post-conversion issues.
  • Stop as many services as possible, especially any that run databases. Disk2VHD essentially captures an application-consistent backup, but it will have superior results if all applications are closed when it runs. This also prevents anyone from using those services. Anything that happens to the system after the Disk2VHD process begins will be lost.

Disk2VHD Usage

There are two ways to use the Disk2VHD tool for P2V in Hyper-V. The first is in interactive GUI mode. The second is via command-line, which is useful if you need to use scripting for such things as handling large batches.

Before starting, shut down all applications and stop any vital services especially if the machine to be converted runs any databases. I/O is paused for the conversion (if you choose the option for VSS) but many applications won’t know to flush active buffers.

[optin-monster-shortcode id=”u4bw5fa5efzfughm”]

Using Disk2VHD in GUI Mode

Copy the “disk2vhd.exe” file to the computer whose drive(s) is/are to be converted and double-click on it from that computer. You’ll be presented with a screen similar to the following:

Disk2Vhd Main Screen

Disk2Vhd Main Screen

That screenshot was taken from a Windows 2012 R2 computer; some older operating systems will not have the “System Reserved” partition. If the system that you’re creating a VHDX from has this partition, you’ll need to include it if you wish for the VHDX to be bootable.

You’ll first need to select a destination in the “VHD File Name” text box. The button at the end of that line with the triple dots serves as a browse button. If keeping the option for VSS snapshots, it’s perfectly acceptable to create the VHDX(s) on the same drive that you’re copying as long as there is enough room.

Unless you know that you’ll be using the generated file on Windows/Hyper-V Server 2008 R2 or earlier, check the box to Use Vhdx. It does not matter if the guest operating system is older than 2012.

Once you’re satisfied with all of your selections, click the “Create” button. The software will first indicate that it is creating the VSS snapshot. After that, it will begin the process of copying out the data. If you make any changes to the drive’s data after that, they will not be saved. You can continue to use the system during the copy process.

Command-line Usage

The primary purpose of using the command-line version would be if you need to script this. For instance, if you have purchased Software Assurance for all of your Windows 7 desktops and want to move them into a VDI environment, you could craft a specialized computer login script that relied on “Disk2vhd” to capture the physical Windows 7 systems in your organization.

The help file shows the usage syntax: disk2vhd [-h] <[drive: [drive:]…]|[*]> <vhdfile> 

There is one optional setting and two required ones.






If the drive to be converted is attached to a Windows XP or Windows Server 2003 system, this prepares its hardware abstraction layer

Drive: or *


You can enter drive letter designators separated by spaces OR you can use an asterisk to indicate all drives. You must use the asterisk for the “System Reserved” partition to be included.



Enter the full path and file name of the VHD[X] to be created. UNCs are acceptable.


Both methods will result in the same type of output: one VHD file will be made for each disk in the source. If there is only one VHD to be created, it will be exactly the file name you specified. If there is more than one, each VHD will be the filename you specified with a hyphen and the disk number appended.

Sample drive layout:

Disk2VHD disk manager screenshot

With all drives checked, running the above system through Disk2VHD produces:

VHDs listed

Demo-0.VHD contains the System Reserved and C: volumes, Demo-1.VHD contains the D: volume, and Demo-2.VHD contains the E: and F: volumes.

Test the VHDX

On a system with Hyper-V 2012 or later installed, run the following, substituting in your actual path:

This testing isn’t overly comprehensive, but it can identify any immediate red flags that would prevent it from being usable with Hyper-V.

Create the Virtual Machine

All that the Disk2VHD Hyper-V P2V tool does is prepare the VHDX files. It does not create a virtual machine. You’ll need another tool for that. The following steps will demonstrate using Hyper-V Manager to create the VM using the VHDXs that were output by Disk2VHD in the steps above.

  1. Copy the created VHD files to a location that your Hyper-V host can access them. If you need some guidance on this, open Hyper-V Manager and ensure that the host you want to work with is selected. In the right pane, click on “Hyper-V Settings…” In the dialog box, click on “Virtual Hard Disks” in the “Server” section. The right pane of the dialog will show the folder that the host is currently set to access VHDs from. It isn’t required that you place them in that folder, but you can be certain that the Hyper-V host will be able to access VHDs there.

    copy VHD to Hyer-V host

  2. Once you have placed the files where you want them, go to the Actions pane at the right. Click New, then Virtual Machine to start the wizard.

    New VM: Start the Wizard

    New VM: Start the Wizard

  3. The first page of the New Virtual Machine Wizard is purely informational. Click Next when ready.
  4. The first data screen asks for the name of the virtual machine and the initial location. The name that you choose will be used as a label in all virtual machine tools, including Hyper-V Manager, Failover Cluster Manager, and PowerShell. The name of the guest operating system that you’ll eventually install will not be automatically set to this, and does not need to be the same.
    If you do not check the option to Store the virtual machine in a different location, then all of the virtual machine’s metadata (XML, BIN, VSV, and second-level paging files) will all be placed in the host’s default location. This path will be visible in the grayed out text box. Checking the box allows you to override this location. If it’s never held a virtual machine before, a subfolder named “Virtual Machines” will be created in the path that you specified. Whether that folder is new or existing, another subfolder will be created underneath it that will have the name of the automatically-generated GUID that represents the virtual machine. Security will automatically be configured for you.

    New VM: Name and Location

    New VM: Name and Location

  5. On the next screen (2012 and later), you’ll be asked to choose the Generation of the virtual machine. What you choose here will depend on the source physical machine. If the source ran in the traditional BIOS mode, you must choose Generation 1. If the source was operating in the newer UEFI mode, you must choose Generation 2.

    New VM: Generation

    New VM: Generation

  6. On the next screen, you set the preliminary memory settings for the virtual machine. You only have two options: the amount of Startup memory and whether or not you wish to Use Dynamic Memory for this virtual machine. If you do not wish to use Dynamic Memory, leave the box unchecked and set the startup memory to the amount of memory that you wish the virtual machine to have. If you do wish to use Dynamic Memory, you’ll have to configure the minimums and maximums later. They will be automatically set to 512 and 1TB, respectively.

    New VM: Memory Settings

    New VM: Memory Settings

  7. Next, you’ll need to determine how to connect the virtual network adapter. You can leave it at Not Connected, which means the virtual machine will begin its life without any network connectivity. Otherwise, you can connect it to a virtual switch right away. Be aware that you can’t set any advanced options such as the VLAN here. Whatever you choose, this adapter is always the newer synthetic adapter, which cannot be used to PXE boot a Generation 1 virtual machine. If you need that functionality, it is granted on a later screen.

    New VM: Network Connection

    New VM: Network Connection

  8. After networking, you’ll be asked to configure the first virtual hard disk for the virtual machine. The second option allows you to connect an existing virtual hard disk. Browse to the VHDX file that you created with Disk2VHD:

    VHDX Selection

    VHDX Selection

  9. The final screen is simply a confirmation and your last opportunity to go back and make any necessary changes.

    New VM Confirmation

    New VM Confirmation

  10. Once you click Finish, the wizard undertakes all of the options that you selected and creates the virtual machine. The wizard does not turn the virtual machine on, so you have an opportunity to make any desired modifications beforehand, such as to vCPU count or memory allocation.
  11. Start the VM in Hyper-V Manager. The operating system will go through a hardware detection phase; how problematic this is will depend on the operating system and the hardware involved. Also, the VHDs have been left in a “crash-consistent” state, meaning that they will act as though the machine they are attached to was shut down improperly. This might not mean anything more than answering the “Shutdown Event Tracker” dialog and perhaps restarting once or twice to finalize hardware changes, but you’ll want to validate any application data just to be certain.

    Disk2VHD shutdown event tracker

    (note: the comment was added for the screenshot, not by the Disk2VHD software)


Test your new VM thoroughly. Some software that requires hardware-based activation may need to be reactivated. Some software may be hardware-dependent and won’t run in a virtual environment. If you didn’t connect the network adapter during VM creation, you’ll need to do so before attempting to utilize it. If you are working with a machine that is a domain member, be warned that there will be a name collision; the typical approach is to remove the new VM from the domain and then rename it prior to attaching it to the network. Once it is able to communicate with a domain controller, re-add it to the domain.


Demystifying Virtualized Domain Controllers Part 1: Myths

Demystifying Virtualized Domain Controllers Part 1: Myths

Using domain controllers in a virtual environment is a contentious and confusing issue. I’m going to start this subject by saying that there is no single correct answer. No one piece of advice is going to work for everyone in every environment. The purpose of this article series is to explain the facts so that you can make an informed decision for your own domain.

My 2014 Hyper-V Wish List

My 2014 Hyper-V Wish List

The end of another year is upon us. It’s given us plenty to talk about, and we will carry some of that discussion into the new year. Here are some of the things I’d like to see happen in our industry.


How to Resize Online Virtual Machine Hard Disks in Hyper-V 2012 R2

How to Resize Online Virtual Machine Hard Disks in Hyper-V 2012 R2

Starting with Windows Server 2012 R2, it is possible to re-size a Virtual Hard Disk for a running Virtual Machine on Hyper-V! It was not possible to do so before for an online Virtual Machine running on Windows Server 2012 and earlier Hyper-V versions.

Let’s have a look at some of the benefits this feature offers and requirements before you dive in and use it. (more…)

Storage and Hyper-V Part 5: Practical Designs

Storage and Hyper-V Part 5: Practical Designs

In the previous parts of this series, our focus was on the basic concepts and theory involved with storage. With this installment, we’ll look at some of the ways you can approach your own storage challenges.

Part 1 – Hyper-V storage fundamentals
Part 2 – Drive Combinations
Part 3 – Connectivity
Part 4 – Formatting and file systems
Part 5 – Practical Storage Designs
Part 6 – How To Connect Storage
Part 7 – Actual Storage Performance


There is no one single right way to design storage for a Hyper-V environment. It’s certainly possible to build a storage solution that uses more than one component. In this way, you can employ high-performance hardware to satisfy needs of high-performance virtual machines while allowing slower and lower-cost storage equipment to handle your more mundane tasks.

All Internal/Local Storage

If it’s not obvious, this is really only viable for non-clustered systems. There are some third-party tools that allow for storage on a node to serve virtual machines for the cluster, but this goes a long way toward defeating the purpose of clustering: preventing any single node from bringing the cluster down. Some of these tools can also mirror the content of the internal storage in real-time, but the cost of doing so often approaches that of simply using some form of external storage.

In general, I prefer using an installation of the free Hyper-V Server above Windows Server, although the reasoning is a subject for another post. However, something came to my attention during a conversation with Jeff Hicks: if you want to use Microsoft’s deduplication solution and all your VMs are on local storage, you’ll have to use Windows Server. Hyper-V Server does not include this functionality. If your VMs are hosted by another system, then that system’s capabilities will determine your VMs’ storage profile.

A serious consideration for this is VDI. This is a prime application for both Hyper-V Server and deduplication, as the server component needs no licensing and VDI can often get a high degree of savings from deduplication. VDI is also the primary solution that Microsoft’s storage team had in mind when updating deduplication for virtualization loads in Windows Server 2012 R2. If you’re going to be implementing VDI and Microsoft deduplication is desired, consider using a file server on Windows Server 2012 R2 to store them.

Mixing Local and Remote

This is a solution I use on a regular basis. In a cluster, not all virtual machines need high availability protections, and some do well if decoupled from the domain requirements of a cluster. As a prime example, I run domain controllers on local storage. This ensures that if remote storage or connectivity to it is lost, the domain controller will continue to function. Another application can work for is System Center Virtual Machines Manager 2012 R2 with multiple VMs on separate hosts running SCVMM R2 in high availability mode.

Even if the host isn’t clustered, the same principles apply. You may have a guest clustered SQL Server that runs on separate Hyper-V hosts. You can install local domain controllers on each host but place the SQL Servers on fast external storage devices. As an aside, there are now a number of ways to configure SQL Server for redundancy across two or more guests besides using a guest cluster; this post is not about SQL Server so I will not spend any time on any SQL deployment options. Consult a SQL Server expert source for more details.

Internal and External Storage Mix

Internal and External Storage Mix

Mixing External Types

Extending on the concepts in the previous section, you can also mix external storage types. For instance, let’s say that you add a standard print server to the above build and decide to create a cluster of the two Hyper-V hosts. There’s no need to force the domain controllers on to shared storage or convert the SQL Servers to highly available VMs. The exception would be if you also convert the locations labeled SAN LUN 1 and/or SAN LUN 2 to cluster disks or Cluster Shared Volumes (CSVs). Even though it will work perfectly well to have a non-highly available virtual machine in a shared location, Microsoft technically doesn’t support that configuration. All you have to do is not add those LUNs to the cluster’s disks and you will remain in a supported configuration. If you do make the LUNs available to the cluster, then you will also need to convert the SQL Server guests to be highly available.

The print server role can no longer be clustered as of Windows Server 2012. Realistically, this is a good thing. Anyone who’s ever administered a Windows print cluster can tell you that it is a perfectly miserable experience. Starting with Windows Server 2012, the way to make Microsoft’s print spooler highly available is by running it inside a highly available virtual machine. This works out very well, as it’s very tough to really have a print server that uses a great deal of compute resources. Print devices are ridiculously slow in comparison to most anything else in the world of computing, so a print server is often able to control a great many devices without straining itself. Also, the spooler service hits a cap of a few thousand print queues in which it simply cannot effectively manage any more. Adding RAM, disk, or CPU to that system will make no difference whatsoever. What that means is that you’ll just never have a print server that demands much from its hardware. So, if your print server must be in a clustered Hyper-V Server environment to be highly available but will never place a serious demand on your disk, why would you want to place it on high speed storage? The only two acceptable answers are, “We have plenty of leftover space on high speed storage,” and, “We don’t want to place it on high speed storage.” Assuming the latter, you could reconfigure the above so that it looks like the following:

External Storage Mixture

External Storage Mixture

Extending the Building Blocks

As you can see, your Hyper-V Server storage can be very flexible. But, you certainly haven’t seen everything. The biggest thing I’d like to highlight here is the way that SMB 3 storage can be expanded. The diagram at the end of the last section shows a single server with a single shared location. There’s nothing inherently wrong with that. But, that one server represents a single point of failure. If it goes down, so does your print server. For a print server, that’s probably not a big deal as long as you can resolve the issue quickly. Since it’s virtualized, you can restore a backup of the VM to internal storage on one of the hosts or to the shared storage as quickly as it takes for the bits to be copied from your backup media. That’s a lot faster than trying to restore a physical print server.

But, even that may not be fast enough. You may want to put more protection, but not want to spend the money necessary for a high-end SAN device with lots of internal redundancy. Fortunately, you’ve got options. For the above scenario, my first choice would be Hyper-V Replica. Have a standalone standby system with inexpensive internal or direct-attached storage. Replicate the print server to it and have it running an active domain controller. This can be accomplished with only the cost of the hardware and a single Windows Server Standard Edition license (assuming these are the only two VMs, both are running a Standard Edition of Windows Server, and the host performs no other roles).

You can also use SMB 3/SOFS a front-end for your SAN devices. The benefit here is that you can expose storage that anyone can use, controlled by familiar NTFS permissions. Virtual machines can be deployed without tapping a storage administrator to provision a new LUN. If you’re in a smaller environment without a dedicated storage admin, you may not use your SAN often enough to feel really comfortable with creating and configuring LUNs every few months when a new deployment need arises.


The options presented here are just a few ideas to get your design strategy started. It is by no means all-inclusive and I doubt that anything that fits in a blog post ever will be. Feel free to leave any other approaches that you’ve discovered in the comments, as they’ll no doubt be useful to others.

In the sixth part of this series, I’ll jump into some how-tos so you can see how to connect your storage successfully.


Page 20 of 27« First...10...1819202122...Last »