Windows 7 Ultimate / Windows Server 2008 R2 offer a way to boot from a VHD, which is an incredible feature if you are testing or if you plan on doing lab deployment. Point in case, we are preparing a bootable VHD that contains VMs that will be imported the first time the machine boots. This means that the only setup required to get this system running, is that lab administrators configure the machines to Boot from the VHD, which can be very trivial using B2VHD Utility we wrote a while back.
When working with a bootable dynamic VHD, you need to be aware that the VHD, when booted, will expand to its maximum size. This is the reason why I start with a very small disk and keep incrementing the size as needed. Hyper-V can handle VHD expansion, but slimming down VHDs, you will need to use third party solution or some other hack.
When you expand a dynamic’s VHD maximum size and you boot back to the VHD, you may notice that your hard drive space is exactly the same as before, nothing has changed. Opening Disk Management will reveal some useful info:
In the image above, you can see the 15 GB that I expanded the VHD, but they are not part of my main VHD, which was the whole point of the expansion. The fix is fairly easy. All you need to do is right click on the drive whose size you’d like to expand and select Extend Volume:
You’ll then be able to select the unclaimed space and add it to your main VHD:
The operation takes about 2 seconds and will finally display your VHD the way it was meant to be: