What to do with a machine that doesn't support Hyper-V...

In my little corner of the world, during the last year (give or take) Hyper-V went from something that a few people were playing with to something that every single person couldn't live without. The huge benefit to us is the 'snapshot' feature, which allows us to instantaneously get a test machine back to clean state.

This left me with one problemĀ - what to do with my old test machine which was too old to support Hyper-V, but too new to just throw away. Fortunately, Win7 came to my rescue by adding support for booting off a VHD (virtual hard disk). Now I can use differencing virtual hard disks, as a poor-man's Hyper-V and still get some millage out of my old test boxes.

Basic reimaging procedure:

  1. Boot to my physical hard drive
  2. Delete the current differencing disk
  3. Create a new differencing disk
  4. Boot back to my differencing disk
  5. Rejoin the domain and install my test software (Visual Studio in my case)

Here is how I set this up:

  1. Installed Win7 to my physical hard drive
  2. After that install completed, I created a new Virtual Hard disk from the Disk Management MMC tool (Computer Management->Storage->Disk Management). I created a fixed Virtual Hard drive but I actually think that I dynamic disk would have been better since most of the parent virtual hard disk will remain empty. I named this file c:\windows7.vhd.
  3. Boot to the Win7 installer again to install a second partition of Win7 on the VHD
  4. After the installer finishes initializing, go to the repair tools and open a command prompt
    • Run 'diskpart'
    • select vdisk file=c:\windows7.vhd.
    • attach vdisk
    • exit
  5. Now continue the Win7 installer, select the virtual disk as the partition to install to. Note that in RC builds, Win7 will warn you that Windows cannot install to this partition, but this warning appears to be ignorable.
  6. After the install completes, install anything else to that parent partition that you need (ex: development tools, baseline libraries, etc).
  7. Boot back to the physical hard drive.
  8. Create a new differing vhd using the 'diskpart' tool (create vdisk file=c:\windows7.diff.vhd parent=c:\windows7.vhd)
  9. Add a new boot menu entry for the differencing vhd, and set it as the default:
    • bcdedit /copy {guid_of_vdisk} /d "Win7 (Diff VHD)" this will create a new boot entry and assign a Guid to it
    • bcdedit /set {guid_of_copy} device vhd=[C:]\windows7.diff.vhd
    • bcdedit /set {guid_of_copy} osdevice vhd=[C:]\windows7.diff.vhd
    • bcdedit /default {guid_of_copy}
  10. Boot to your new diff vhd and test away