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

05 Jun by Eric Siron     26     Hyper-V Articles

Microsoft’s System Center Virtual Machine Manager up through 2012 has a built-in utility to convert existing physical machines to Hyper-V virtual machines (P2V), but not every deployment is large enough to justify the cost of that product. For instance, you may only have one host and two or three machines to virtualize. In VMM 2012 R2, the P2V tool was removed entirely, leaving System Center customers in the lurch. In such cases, Sysinternal’s free “Disk2VHD” product for Hyper-V P2V conversions may be exactly what you need.

Updated 2/1/2014

Obtaining 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.

Usage

There are two ways to use Disk2VHD 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.

GUI Usage

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 you’re creating a VHD from has this partition, you’ll need to include it if you wish for the VHD 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 VHD(s) on the same drive that you’re copying as long as there is enough room.

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.

Setting

Required?

Purpose

-h

No

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 *

Yes

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.

vhdfile

Yes

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

Output

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:

Disk2VHD - List VHDs

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.

Create the Virtual Machine

All that the Disk2VHD Hyper-V P2V tool does is prepare the VHD 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 VHDs that were output by Disk2VHD in the demonstrations 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.

Disk2VHD - Hyper-V - 1

 

2.  Once you have placed the files where you want them, go to New->Virtual Machine in the Action pane of Hyper-V Manager. If it starts on the “Before You Begin” screen, click “Next”. Name the virtual machine appropriately and relocate it if you like. Click “Next”.

Disk2VHD - Hyper-V - 2

3.  On the next two screens (not pictured), you’ll establish how much memory to assign and what network to connect the virtual network adapter to. You may wish to leave the network adapter unconnected to avoid coexistence problems with the original VM. Configure these as desired and click Next to reach the “Connect Virtual Hard Disk” screen. You have three choices.

a.  If you want to install a new operating system and just connect those drives to be read as standard data disks, you can “Create a virtual hard disk”. You’ll need to install the operating system to it.

b.  If you want to attach the bootable VHD now, click “Use and existing virtual hard disk” and type in or browse to the name of the VHD to use. You cannot attach any other drives at this time.

c.  You can choose to “Attach a virtual hard disk later”. Once the wizard is complete, you can change the properties of the VM to connect the drives.

Disk2VHD - Hyper-V - 3

4.  Click “Next”, ensure everything is as desired, and click “Finish”.

5.  The VM will be created and left in the “Off” state. If you didn’t attach any VHDs or if you have more than one to attach, right-click on it in Hyper-V Manager and click “Settings…” Highlight any drive controller (IDE Controller 0, IDE Controller 1, or SCSI Controller) and click “Add” on the right.

Disk2VHD - Hyper-V - 4

 

6.  This will present the following screen. You can select the controller (it will default to whichever you highlighted) and then browse to the VHD file (or you can create a new one). Remember that boot drives must ALWAYS be connected to the IDE chain. Repeat this step until you have added all drives. You don’t need to click “OK” or “Apply” between adds; just click on a controller in the left pane and continue attaching/created drives until you’re finished. If for some reason a SCSI controller wasn’t created or if you need more than one, you can add it using the “Add Hardware” button at the top-left of the “Settings” window.

Disk2VHD - Hyper-V - 5

7.  Modify any other settings of the virtual machine as desired. Click OK.

8.  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 - Hyper-V - 6

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

Wrap-Up

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 renaming it prior to attaching it to the network. Once it is able to communicate with a domain controller, re-add it to the domain.

Have any questions?

Leave a comment below!

 

Backing up Hyper-V

If you’d like to make backing up your Hyper-V VMs easy, fast and reliable, check out Altaro Hyper-V Backup v4. It’s free for up to 2 VMs and supports Hyper-V Server 2012 R2! Need more? Download a 30-day trial of our Unlimited Edition here: http://www.altaro.com/hyper-v-backup/.

 

Receive all our free Hyper-V guides, checklists and ebooks first via email!

(Don’t worry, we hate spam too!)

Eric Siron

I have worked in the information technology field since 1998. I have designed, deployed, and maintained server, desktop, network, and storage systems. I provided all levels of support for businesses ranging from single-user through enterprises with thousands of seats. Along the way, I have achieved a number of Microsoft certifications and was a Microsoft Certified Trainer for four years. In 2010, I deployed a Hyper-V Server 2008 R2 system and began writing about my experiences. Since then, I have been writing regular blogs and contributing what I can to the Hyper-V community through forum participation and free scripts.

26 Responses to “Using Disk2VHD for Hyper-V P2V (Physical to Virtual) Conversions”

  1. Addy@ Copy Machines

    I was just looking for this information for a while and found it here. But everything was ok with me, when I came at number 8* I’ve got bit confused about operating system issue. Can you please tell me that, which operating system is very suitable for this disk2vhd software? and what hardware needed. Thanks

    Addy

  2. Another Visitor

    ?? “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 renaming it prior to attaching it to the network. Once it is able to communicate with a domain controller, re-add it to the domain”

    This is not consistent with my purpose or understanding of this procedure.

    My intent is to move an existing Hardware installed OS to a virtual existence and KEEP the machines domain name OS and application configuration. Reason for the move is to keep the machine active but retire the old/ailing hardware platform it runs on.

    If I didn’t want to keep the machine name and configuration, I would just go ahead and create a new VM and install a clean copy of the OS.

    The warning should be to disconnect the physical computer from the network before activating the VM to replace it.

    Then rename the old physical computer before adding back to the domain if you want to keep using it for some other purpose.

    Other than that, thanks for the post. The step by step is clear and this utility will be helpful for moving a workstation i have with an application registered to the OS installation to a virtual environment before the box dies on me.

    • Eric Siron
      Eric Siron

      That’s a good observation and you’re absolutely right. I’ve done it that way myself. Perhaps I was thinking of cloning when I wrote that.

  3. H Feenstra

    Thanks!! It helped me getting everything in place and backed up as a vhd

  4. PrazAU

    Great article . Learned about conversion using-disk2vhd-p2v
    Using Disk2VHD for Hyper-V P2V

  5. Giacomo Venza

    Thank you for the guide and sorry for my poor english…I hope you’re able to understand me!!
    I have this big problem : I followed the guide with an XP machine and everything goes fine.
    Now I’m in a disaster recovery situation : the RAID controller of one of my two domain controllers (with exchange server 2010 on it) stopped working correctly…after thousands of tries I was able to restart the OS and immediatly I tried to virtualize it from the operating system to an USB disk (as I did with the xp machine). Disk2VHD finished correctly so I detached the usb drive and I copied the VHD from it to my vhd location in the other windows server 2008 r2 machine with hyper-v (C:\users\public\documents\hyper-v virtual harddisks). But when I try to create the vm and attach the vhd it stops beacuse of no permissions (and the vhd files shows a lock icon on it)…any suggestion?

    • Eric Siron
      Eric Siron

      Stop: If this is one of two domain controllers, is the other one functional? If so, then why are you trying to recover the dead one? It is much, much, much easier to build a new domain controller and join it to an existing domain that it is to recover a dead or dying domain controller.

      I am not certain exactly what is preventing you from attaching to the VM. The file should have received the proper permissions once you copied it to the destination location. Try accessing the security page on its property sheet and forcing it to inherit permissions.

  6. David McKenna

    I am trying to use the command line to automate this task, my issue is that I have an external HDD plugged in which I would like to exclude however I need the System Reserved Partition. I understand without the external HDD I could do the following:- disk2vhd * \\\Share\SBS.vhd or specify the drive C: D: E: etc however there is no way to specify the System Reserved Partition or to exclude the External if using *. Am I missing something?

    • Eric Siron
      Eric Siron

      I don’t think you’re missing anything. The command-line portion of Disk2VHD is not well-developed.

  7. Ted Larsen

    Good Article, thanks Eric. One question: Have you ever had success running Disk2VHD from some sort of bootable media, like a USB in an ‘offline’ mode? I know you listed the Command Line functionality above, but have you ever tried creating some sort of bootable stick (with DOS, or some other environment) that you could then run disk2VHD from a command line to .vhd an existing Hard Drive to a different existing hard drive on the machine, while outside of the host OS?
    I have a specific need to do this, but can’t find an tried and true way to do this.

    Thanks!

    • Eric Siron
      Eric Siron

      I’ve never tried. I’m not sure what the exact mechanism is that Disk2vhd uses to do its business. It may need functionality from the Windows OS that you won’t have in a stripped-down boot environment.
      Not sure if it changes your scenario any, but I’ve never had problems using Disk2vhd to save the output VHD files on an internal drive in the same machine, even if I’m including the target drive in the capture. It works through VSS so there’s no strange issues.
      For offline things, I’m actually a big fan of Clonezilla. I wrote this article for V2P, but there’s no reason it wouldn’t work for P2V as well.

  8. Dave Palanker

    Hi Eric,

    I fix PCs. I want to make copies of HD before I work on them. Here is what I am trying to do. I attach a customers HD to my laptop. I want to make a VHD of this drive. I have another external drive, 1 TB also attached. This is where I want to store it, and other clones I make. I want to test this. I used the Disk2vhd to make a .VHD file of the drive which is 232 GB, and only a folder on it with 10 GB of data, that’s it, so it says space required was approx. same size as folder. I then go into the source drive and erase the 10 GB folder. I want to restore the original contents I just made a virtual drive of. I am going around in circles trying this. I tried the VHD machine create/attach that win 7 has, it makes the .vhd, but I don’t know how to restore it. What am I missing, I need another program I suspect. I don’t want a bootable drive, just put back what I cloned. Any advice would be much appreciated.

    Thanks,

    Dave

    • Eric Siron
      Eric Siron

      If you just want a folder, is it necessary to clone the entire disk?

      I’m a little confused by your symptoms. Are you saying that the mount doesn’t work? I’ve never worked with a drive that large, but I’ve heard that Disk2Vhd doesn’t like big disks. I’m not sure if that problem is restricted to Virtual PC deployments.
      You might look at this blog post. At the very end are ways they fixed it for VPC. Maybe you just need to shrink the virtual disk down to something smaller.

  9. Vishwajeet

    I used disk2vhd and found one extra partition which is unallocated gets created every time. The network card issue as well as there is team in to the physical server.

    Please suggest me best process i am doing something wrong.

    • Eric Siron
      Eric Siron

      It’s going to bring over whatever it finds. It’s not going to magically uninstall drivers or reconfigure any hardware for you.

  10. Mac

    I need to P2V my Avaya CC Server running on an old HP ML Rackmount unit. My question is if perform a P2V using disk2VHD and just mount the drives as a bootable drive on a VM inside Hyper-V .. then what happens to the drivers from the HP Server that are already a part of the Disk image that i previously created ? Also – anything changes OS Licensing wise (windows 2003 R2) ?

    • Eric Siron
      Eric Siron

      The entire contents of the disk come over as they are. Hopefully the drivers just go dormant when the underlying hardware doesn’t show up. I try to clean off all non-essential drivers before a P2V just to be sure.
      Licensing is the same. The hardware that you install to must have an available Windows Server 2003 license. It will attempt to re-activate on first boot after being virtualized.

  11. Hayden Hancock

    Do you have any experience when using this tool with encrypted drives? We currently have BitLocker on all physical disks. We followed this guide but get a MBR error when starting from Hyper-V. Any help would be much appreciated.

    • Eric Siron
      Eric Siron

      I do not have any such experience, but it does not surprise me that it fails. Even if you’re performing this for legitimate reasons, this is one scenario that BitLocker is designed to prevent.

  12. Hayden Hancock

    Yup, that’s what I figured. I am going to try to suspend BitLocker and clone it again to see if it resolves my issues.

  13. Seyed Ismail

    Thanks a lot, I learned about Hyper-V and Disk2VHD.

    It really works!!!!

  14. Kenneth

    Hi,

    I did P2V with Disk2VHD and SCVMM 2008, it goes through fine without error.
    I try to boot VM Windows 2003 (not R2) SP2 and I get to chose Windows 2003 at the OS identifier menu. It goes to the next screen as it would boot into Windows but instead is just stays in a black screen with blinking cursor in the upper left-hand corner.
    I tried to do fixmbr, fixboot, bootcfg /rebuild, still no go.

    Any idea?

    Thanks

    • Eric Siron
      Eric Siron

      2003 P2V has always been troublesome in Hyper-V. I’d imagine it’s tripping up on some piece of hardware.
      You can look over the article I have on my own blog and see if that works. It’s time-consuming, but I was personally able to get every P2V 2003 system of mine to work by doing all that.

  15. LuisJ

    Hi Eric, do you recommend a solution as describred in your article for a Exchange 2010 migration from physical to a virtual Microsoft Hyper-V 2008 R2 environment?

    Thank you

    • Eric Siron
      Eric Siron

      I don’t think I would P2V Exchange. Migration would likely result in a smoother overall experience.
      But, as long as you have all the Exchange services stopped, Disk2VHD would probably move it as successfully as any other P2V application.

  16. JF Ouimet

    Great procedure !

    Had to use Oracle Virtual Box (as Virtual PC doesn’t support 64 bits).

Leave a comment