How do I create a virtual image of a working Windows installation with Disk2vhd?

Learn how to take your current Windows installation and create a vhd image that can then be imported into your virtual machine tool of choice.

For so many administrators and developers, virtual machines can be a very easy way to save time and money as well as beef up security. For Microsoft Windows users there are a few options for creating and using virtual machines. You can employ either Microsoft Virtual PC or Microsoft Hyper-V virtual machines to run instances of a Windows operating system as a guest on a Windows host machine. But that leaves the question of where do you get the images?

You can always install a fresh image or visit one of a number of sites that allow you to download various images in vhd format that can then be imported as a virtual machine. But what if you want to create your own virtual machine? What if you have created the perfect installation that you want to import as a virtual machine? How does one do that? Of course, there are tools for just that task. One of those tools, Disk2vhd, was created by Sysinternals (makers of many fine applications).

In this tutorial, you will learn how to take your currently running Windows installation and create a vhd image that can then be imported into your virtual machine tool of choice (so long as it supports vhd files).

This blog post is also available in PDF format in a free TechRepublic download.

How it works

Disk2vhd can create images from any drive attached to a PC so long as the drive has the necessary files. The tool works by using the Windows' Volume Snapshot capability found in any Windows operating system, starting with XP and later. In fact, the best method of using this tool is to save the .vhd file to an externally attached drive. If you save the image to the same drive you are taking the image from, performance will seriously degrade. Since the process is already fairly slow, you do not want to make matters worse.

You will also need to make sure that you have plenty of space on the target drive. Most likely the installation you are using to create your image is not a clean installation, but a specific image with various applications and configurations. This will cause the size to grow quite a bit. This also brings up another issue: If the drive is a VFAT-formatted drive, your image file cannot be over 4GB. So make sure either your file system will accept larger files or your vhd file is less than 4GB.

So, with that said, let's take a look at how this tool is used.

Getting and installing

There really is no installation involved with Disk2vhd. This application is not an installer file but a self-contained binary, which can be executed from any location (even a thumb drive). So when you download and extract the Disk2vhd file, you will see four files inside the newly created Disk2vdh directory. Of these files, the one you will use is disk2vhd. You can either double-click that file from within the Disk2vhd directory or pin the file to either the Start menu or the Quick Launch menu.

When you start the application, you will see the main window (Figure A). There is no configuration window, which makes this tool simple to use.

Figure A

The only configuration options available are selecting the volumes to include and determing the location of your target file.

As you can see, I have set the location of my target file to be on an external hard drive. This ensures that I have enough space for the image as well as keeps the process from dragging my machine to a crawl.

Once the minimal options are taken care of, all that is left to do is to click the Create button. Once you have done this, the process will begin. Depending on the size of your image file, this process could take some time. During the creation, you will see the progress bar very slowly inch across the window (Figure B).

Figure B

The time indicated on the bottom right of the window is an approximated completion time. In this case, the completion will take about thirty minutes.

Once the process is complete, you will have a file on your target drive named after your PC with the extension .vhd. It is this file that you can then import into the virtual machine tool of your choice. Without going into the specifics of each virtual machine tool, the process of adding these image files is simple:

  • Create a new virtual machine with the characteristics that match the machine used to create the image file.
  • During the process of creating the virtual machine, use the vhd file as the new machine's IDE disk.
  • When you first boot the new machine, the virtual machine tool will detect the machine's hardware and automatically install the drivers.

Those steps could vary, depending on the virtual machine tool you use.

Final thoughts

If you are an administrator who depends on virtual machines, then you need to take advantage of this incredibly handy tool. With Disk2vhd, you can create a very specific machine image for deployment via virtual machine.

Stay on top of the latest XP tips and tricks with TechRepublic's Windows XP newsletter, delivered every Thursday. Automatically sign up today!


Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website

Editor's Picks