Creating a Virtual Hard Disk Image from a Running OS with Disk2vhd
Disk2vhd is tool from Microsoft’s Sysinternals group that allows system administrators to create virtual hard disk images (VHD) of running operating systems loaded on physical hardware.
VHDs are the Microsoft’s Virtual Machine disk format used in Microsoft Virtual PC or Microsoft Hyper-V virtual machines (VMs).
There are other physical-to-virtual tools that are available to create images out of installed operating systems running on physical hardware; the main advantage of the Disk2vhd tool is that you can run it on a system that is up and loaded as it uses the Windows’ Volume Snapshot capability to create a point-in-time snapshot of the volumes you want to include in a conversion.
The Disk2vhd tool also allows for the ability to create the VHDs on other local volumes including the active one being converted.
[NOTES FROM THE FIELD] – While the tool does allow you to create the file in this manner there is a performance hit; it is always better to create the VHD is on a different physical disk.
Once you download the tool from the Microsoft Website (which still shows as a Sysinternals download point at http://download.sysinternals.com/Files/Disk2vhd.zip) you would open the ZIP file to expand the files to a location to run them.
Once that is done you would run disk2vhd.exe and accept the Sysinternals Software License Terms which would then bring you to the application’s main view.
The default view of my physical system is shown below. You’ll notice that the tool automatically selects all of the available drives and sets a default location and name where to drop the VHD file if you were to accept the defaults and select CREATE.
Since a couple of these partitions are just data and others are alternate operating systems rather than my base image that I am currently running (Windows 7 Ultimate Edition x64) I am going to clear all the defaults with the exception of the C:\ which is where my Windows 7 install resides.
I would like to avoid the performance hit so I will change the default file location to my DATA drive.
Once I have made the changes and hit the CREATE button you’ll notice the progress bar will begin and it will create an empty file holder at the destination directory as it builds as shown in the second image below just above the active application window.
Once the image is created you’ll see that its actual size is shown and it is ready to be mounted within the Virtual PC environment.
I am running the Virtual PC environment of Windows 7. When I attempt to walk through the steps to mount the virtual machine under Virtual PC in the sequence of steps show below you’ll notice I have a critical failure and cannot continue.
This is because Virtual PC doesn’t support the Multiprocessor Specification and it will not be able to boot VHDs captured from multiprocessor systems.
In order to boot this successfully I would need boot my Server 2008 system running Hyper-V in order to mount the VHD (after configuring everything necessary in the Hyper-V Manager as shown below).
Disk2vhd Best Practices and other Support Notes
Briefly, it is important to note what is supported under the tool and what are the recommended operational boundaries.
- Disk2vhd can run on the following operating systems: Windows XP SP2, Windows Vista and Windows 7, including x64 systems.
- On the server platform side it supports Windows Server 2003 SP1 and Windows Server 2008, including x64 systems.
- With respect to Virtual PC, it can support a maximum virtual disk size of 127GB. If a VHD is created from a larger disk, it will not be accessible from a Virtual PC VM.
- Virtual PC doesn’t support the Multiprocessor Specification and it will not be able to boot VHD’s captured from multiprocessor systems.
- You cannot run VHDs on the same system from which they were created in an effort to boot from them. By default, Windows assigns the VHD a new disk signature to avoid a collision with the signature of the VHD’s original source disk. Because of the way that the operating system references disks in the boot configuration database (BCD) by disk signature, this forced change causes the VM to fail because after the change it cannot locate the boot disk.
- You can use Disk Management or Diskpart utilities under Windows Server 2008 or Windows 7 to mount the VHDs directly and view their contents through Windows Explorer or via the command line as if they were any other available volume.
- Disk2vhd includes command-line options that enable you to script the creation of VHDs (as outlined below, provided from the tool’s help notes).
Usage: disk2vhd <[drive: [drive:]…]|[*]> <vhdfile>
Example: disk2vhd * c:\vhd\snapshot.vhd
In this tutorial we took an overview look of the Disk2vhd tool and also reviewed some of the best practices.
Additionally we walked through running the tool and collecting an image from a hardware build as well as reviewed the failure we received when we tried to launch a multiprocessor image capture on Virtual PC due to the limitations of that desktop product.
I am always looking forward to any feedback you have on this or any of the articles I have written so feel free to offer your feedback.
Additionally, I would welcome any suggestions topics of interest that you would like to see and based on demand and column space I’ll do what I can to deliver them to you.