I’d been round in circles a few times and had eventually settled on a technique that involved a 2nd drive in the UltraBay slot of my Lenovo W510 to host “expanded” VHDs when @GarryMartin tweeted me to point out there’s a registry setting that controls whether or not a native-boot VHD gets expanded on boot.

In a native boot VHD scenario, Windows will expand a dynamic VHD to its full size with disastrous consequences if there’s not enough space on the disk. However, as Garry pointed out, it’s possible to disable this behaviour with a registry setting.


Again, I repeat, mess with these things at your own risk. Changing registry settings carries a risk as does crossing the road. Be prepared to take a risk or stay where you are. But whatever happens, just remember it’s not my fault.


And lo and behold did that not work for me! So my 50GB VHD file which represents a roughly 50GB OS image created using Disk2VHD fitted easily on my 160GB SSD drive alongside its friend, pagefile.sys (2GB in this case). Note that you need to be very careful not to run out of space on the host using this approach. It’s a bit like switching to throwing a runtime exception rather than a compile error.

All was well and everyone in Ormond Towers expected to lead a happy an fulfilling life until I enabled BitLocker (a very sensible and reasonable requirement that my employer stipulates for mobile PCs). The BitLocker encryption process trundled away (it takes a while) and ultimately failed. Actually, I can’t remember now whether it BSODd or simply threw an error towards the end of the encryption process. Either way, it threw its hands up and fell over.

I re-imaged the drive and did the whole thing over again just in case I’d made a schoolboy error. This time I kept a closer eye on things (rather than disappearing off to watch an episode of Twenty Twelve) and noticed (in Explorer) that the BitLockered drive was filling up (this is normal AFAIK) and the “host” drive was doing the same.

Once BitLocker encryption is complete you get that space “back” on the encrypted drive but, it appears, not on the host. I was again exceeding my available storage (VHD + pagefile > host size) ie I was effectively hitting the “expand on boot” problem again, but this time “expand on BitLocker encryption”.

The only way around this was to shrink the VHD file originally created by Disk2vhd. Given I’d flattened my OS partition to try this out, the easiest way to do this was using my Win7 install media and Diskpart. Using this technique I opted to shrink the drive by 5GB – space for the pagefile (2GB) and a bit spare.

Once I’d done that I copied the VHD back to the local “host” drive, booted it (no need to change anything as the BCD store was already setup to boot this VHD file – I just had to keep the same filename) and re-BitLockered. Success!

Below you can see the resulting drive configuration.

C: is the “native boot VH

D” – the boot partition that this OS is running off

D: is a partition on the VHD – required for BitLocker

E: is the “host” drive

F: is some extra storage in my UltraBay slot

2011-05-18 15h56_34

If I open C: in Explorer it just looks like a standard Windows install

2011-05-18 16h02_00

And if I open E:, all I see is the VHD file that I’m booted from

2011-05-18 16h02_48

In my next post, I’ll do a step by step of how to get this working if you want to.

Why would you want to? I see a few benefits:

  • I can “snapshot” my OS install at any time and have a completely isolated copy where I can install / test things
  • Taking a backup is a simply xcopy to an external drive
  • Moving drives is as simply as copying a VHD file from one to another