Windows 7 Boot from VHD – A Few Gotchas

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.

  1. 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!
  2. 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.
  3. (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.

About Howard Dierking

I like technology...a lot...
This entry was posted in virtualization, Windows 7. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Tyler

    This article suggests upgrading the VM’s OS to 2008 R2 to boot to the VHD.. did you have to do that?

  • Jon Galloway

    Scott’s followup post points to a prep script that handles a lot of this stuff, like sysprep.

  • hdierking

    @jeremiah – that may be true for svr – however, on my Win7 client running on my laptop, there’s simply no comparison between running the vm virtualized vs. booting into it. Even if the reason has less to do with the hardware and more to do with not loading the full host, the end result is that booting into the vhd has been a much better experience for me.

  • jeremiah

    the performance impact of running virtualization is negligible. In fact, the Windows servers I have running under Hyper-V actually seem to run FASTER than on the hardware directly. No I’m not kidding. I have 10 Windows Server 2008 Enterprise VMs running on a single $5000 BladeCenter blade and they run excellently. I even have Exchange 2007 running in a VM, on a VHD, and it runs excellently.

  • Tom de Koning

    Be aware that there still is a performance penalty, albeit not as hefty.