When I first read about the capability in Windows 7 to natively boot a VHD, I was ecstatic – finally I could install all of my beta software in a sandboxed environment without having to put up with the performance cost of virtualized hardware. So I read through several posts such as this one from Scott and then proceeded to modify my boot record accordingly – pointing it at a vhd that I had already created via Windows Virtual PC. As those of you who have played with this already know, it’s not quite that simple, and it took me a little bit of time and digging to figure out exactly where the problems were – so I want to take a second and list out the major gotchas that I ran into – hopefully this will save you some extra digging.
- By default, Windows Virtual PC puts both your vhd and vm config files in “C:\Users\[you]\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines” – this folder has restricted permissions and while pointing your master boot record at a vhd file found in this location will not raise an error when running bcdedit, it will rear its ugly head when you reboot. And while the error is recoverable and harmless, it looks a bit scary – something about the master boot record database being corrupted – yikes!
- You must run sysprep on the vm that you intend to boot from – and you need to use the “generalize” option. Otherwise, your system will blue-screen when trying to boot your vhd because it will try and use the virtual machine drivers and not auto-detect the drivers for the physical hardware.
- (this was the one that gave me fits) Pay attention to the size of your vhd file, even if you’re creating a dynamically sized disk. By default, the disk size for a dynamically expanding disk (when created through Windows Virtual PC) is 130 GB. If this size exceeds the amount of available storage on your physical disk, your vhd will start to boot and then blue-screen. Fortunately, the stop error is actually comprehensible – it will tell you that you don’t have enough physical storage to enable the vhd to expand to its maximum capacity (or something equivalent). So in short, be explicit in configuring your vhd, and make sure that the vhd size doesn’t exceed available physical storage limits (even on dynamically expanding disks).
Once I got through those problems, I was able to boot from my vhd and created a nice little testing environment for VS 2010.