By Val Bakh
There are three types of VHDs: fixed, dynamically expanding, and differencing. A fixed VHD is similar to a regular hard disk in that the size of the .vhd file corresponds to the VHD’s capacity. A dynamically expanding VHD is like a balloon: it starts tiny and grows as you put more data on it. And the best VHD for a virtual lab is a differencing VHD, which is like a dynamically expanding child of another VHD. With a differencing VHD, the parent functions as a benchmark, or a starting point, and remains intact; everything that changes is written to the child.
On the computer where you want to implement your virtual lab, install Windows Server 2008 R2 and add the Hyper-V role. Then create a virtual machine (VM) with a dynamically expanding VHD and install Windows 7 (or whatever supported version of Windows you want to play with). Use the Sysprep tool to generalize the installation, shut down the VM, and protect its .vhd file by making it read-only. This will be your base VHD for all future Windows 7 VMs. From this point on, you can produce a brand new Windows 7 VM in a matter of minutes. All you need to do is create a VM with a differencing VHD whose parent is the aforementioned base VHD. When you start the VM, it automatically goes through a mini-setup, and five minutes later, you have a pristine fully functional Windows 7 VM.
At this point, take a snapshot of the VM. The system automatically creates a new differencing VHD whose parent is the previous differencing VHD. Now you are ready to start testing. When you are done with one batch of tests and need to return to square one for the next batch, you can simply apply the snapshot to the VM. The last differencing VHD will then be discarded, and a new one will be created in its stead. The entire process usually takes mere seconds to complete. In this manner, you can create a snapshot at any significant point in your testing and later return to that point whenever you want.
Create one base VHD for each version of a guest operating system that you need in your lab. The same base VHD can be the parent of multiple VMs. Thus, instead of maintaining a separate base image for each VM, you need to maintain a separate base image for only each version of an operating system. This approach saves a lot of time and effort.
However, this method—running multiple VMs on differencing VHDs that have a common parent VHD—is not something that you should do in a production environment. For production, using a dedicated fixed VHD for each VM will probably work better because it will provide better performance and reliability. In production, performance and reliability are usually more important than the ability to start from square one three times a day.