Thursday, January 13, 2011

Windows 7: Creating a Bootable Virtual Hard Disk (VHD)

As described in other posts in this blog, I was in the process of installing Windows 7.  I had discovered virtual hard disks (VHDs).  I was at the point of wanting to create a VHD that would boot Windows 7.  This post describes that creation process.

There appeared to be several ways to create a bootable Win7 VHD.  I could:

  • install it from scratch, using the Windows 7 installation DVD; or
  • convert an existing physical Win7 installation into a bootable VHD; or
  • convert a Windows Imaging format (WIM) file to a bootable VHD; or
  • deploy a WIM file into a VHD without conversion, and then boot the WIM file.
The fourth option was interesting, but I did not discover it until later.  The first option was tempting, insofar as it, too, would avoid a conversion process.  My prior experience in converting physical Windows XP machines to VMware virtual machines (VMs) using VMware Converter suggested that a conversion process might leave me with a buggy, poor-functioning VHD.

I chose to start with a conversion option nonetheless because I felt it offered some advantages over the approach of installing Win7 from scratch in the VHD.  For one thing, I had heard that a bootable Win7 VHD would not be upgradeable.  In that case, I would probably want to have a reference source -- a physical installation, that is -- that I could go back to, upgrade, and repackage into a new VHD.  Maintaining a reference physical installation could also mean that I could start with a smaller fixed-size VHD and then create a new, larger one as the size of the total Win7 installation grew, instead of taking what sounded like the more problematic approach of using a dynamically expanding VHD.  I also thought it would probably be handy, at times, to have that physical installation readily available, in case something went wrong with the VHD, or if it turned out that there were limitations on what the VHD could do.  That concern came from working with Windows XP VMs, in VMware, that were not able to access USB devices that a physical WinXP installation could access.  In addition, of course, a successful conversion strategy would save me the whole process of doing yet another installation from scratch.

As I looked into the conversion options more closely, it seemed there were a number of useful tools for the purpose.  WinImage was said to be a capable shareware, command-line tool that could create images in VHD format.  WIM2VHD was a freeware tool from Microsoft for the same purpose.  It appeared that Acronis True Image might be able to restore an image to a VHD.  Disk2VHD, another Microsoft offering, provided a way to create a VHD on a Win7 machine while it was running.  I preferred a GUI, if I could get it, and Acronis had recently disappointed me, so I narrowed down my choice to the two Microsoft tools.  Now it was just a question of whether I wanted to use WIM2VHD to convert a WIM to a VHD, or Disk2VHD to convert a running machine to a VHD.  I decided the latter was the more straightforward approach, so I started with that.

To create the VHD with Disk2VHD, I downloaded, unzipped, and ran Disk2VHD.  It was a portable program, so it did not need to be installed.  It recognized the partitions on my system, and asked which ones I wanted to put into the VHD, and where I wanted the VHD to be created.  For the target location, I designated a Win7 software RAID0 partition.  The source was a 70GB partition of which 32GB was used.  The target was a 100GB partition.  The process of creating the VHD (with source and target on different hard drives) took about five minutes.  The resulting VHD file was 26GB.  This, unfortunately, was not the right size.  It would not be big enough to accommodate any growth in the size of the Win7 installation.  It appeared that there were ways to expand it, but the methods I saw seemed to promise another layer of hassle, complexity, and potential failure. 

Back at the drawing board, WIM2VHD was advertised as creating sysprepped VHDs for native VHD booting.  It turned out that WIM2VHD was an automated way of doing the "deploy" (fourth) option listed above, so there were really only three options.  To run WIM2VHD, I had to download and install the 1.7GB Windows Automated Installation Kit.  I found a Microsoft website with authoritative information about VHDs.  At this point, however, I decided to postpone this project in favor of other pursuits.

0 comments: