We have seen over the past few years that there has been an increase in virtualisation in servers and increasingly with desktops. A new feature available with Microsoft Windows 7 and Microsoft Windows Server 2008 R2, although not virtualisation in itself, is the ability to natively use and even boot from VHDs (Virtual Hard Drives).
This feature allows you to install the operating system on a VHD file and provide for quick recovery of failed machines by replacing the VHD with the original. This is both practical in the enterprise as well as simple recovery in the home market Windows 7 install to VHD To enable this there is nothing particularly special that we need to do to begin. So just insert your installation DVD and boot from the DVD to begin. When you come to choose the partition or disk to install into, obviously, at this stage we only have our new blank disk and the GUI does not provide a mechanism to create the Virtual Hard Disk (VHD).
We must, then, press SHIFT + F10. This should open a command prompt window. Then follow these steps (assuming you have just 1 fixed drive as in my example). Step by step from the command prompt:
select disk 0
clean (if partitions exist and you want to delete exiting partitions)
create part primary size=200 (create the system partition of 200mb for bcdboot)
format fs=ntfs label=system
quick active (sets this to be the bootable drive)
create part primary (create a partition on the rest of the disk for drive c to host the vhds)
format fs=ntfs label=boot quick assign letter=C
create vdisk file=c:win7.vhd maximum=25000 type=fixed ( here we create the 25GB vhd to install Windows 7 onto, setting it to fixed rather than expandable will help prevent fragmentation as the drive grows)
select vdisk disk=c:win7.vhd
create part primary (creates a partition on the vhd)
format fs=ntfs label=win7
quick list vol
exit (exit from diskpart)
exit (close command prompt)
(Did you keep up with all of that?!)
Now continue the installation So now we have the VHD, to continue with the install we just need to refresh the display in the GUI and choose to install onto the volume label win7 (in my example). The installation then proceeds normally and once installed we should see that Drive C: is the VHD and Drive D: is the physical drive that contains the VHD file that we boot from. I would recommend storing data on Drive D: to keep your data separate from the OS. This also means that in a recover situation you just need to place the VHD and you data is still available on the D: Drive.