My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana - Jon Galloway

My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

Summary

  • Windows 7’s Boot to VHD works as advertised – native speed, virtual machine flexibility.
  • I came up with some tips and tricks which you might find useful
  • Having to reboot without hibernate to switch to the VHD machine means it’s a lot less useful than I’d hoped.

Background

I’ve recently been running some early releases developer tools which came with the “install on VM’s if you don’t want your computer to catch fire” warning. That seemed like a good time to back off on my “VM’s are for sissies” stance and get my VHD on. After verifying that there wasn’t already a suitable VHD available for download, I decided to follow Scott Hanselman’s directions to set up a Boot To VHD instance.

Here’s a very high level overview:

  1. Download the wim2vhd script from CodePlex
  2. Install the Windows 7 Automated Installation Kit (AIK)
  3. Copy ImageX.exe from the the AIK install into the same folder as the wim2vhd script
  4. Run the script
  5. Mount the VHD in the Windows 7 disk management screen
  6. Run some funky commands to make the disk bootable

There's a little goofing around at the command line, but it's only a few minutes if you follow the directions. Then your new VHD shows up as an option on boot.

BUT WAIT! I have a few minor modifications. Rather than write a complete walkthrough of the process – since Scott and others have done such a good job there – I’m just going to list some footnotes to the process. I’ve very roughly outlined the steps above; I recommend you read through the following list of tips, then go and follow Scott’s walkthrough and use any of the below tips you think are helpful.

Mod #1: Getting ImageX.exe without installing the AIK

There are copies of ImageX.exe floating around on the internets. I normally wouldn’t recommending using them, I only mention that because the AIK is 1.5 GB. If you’re one of those irrational people that thinks downloading 1.5GB to get a 471KB program, you could search around for “download imagex.exe” If you do that, the CRC for my my 32 bit ImageX.exe – version 6.2.7600.16385 - is 54 BF FA D5. Not recommended, but it is an option.

Note: Dear Microsoft folks that make gigantic SDK’s, please stop. Those might have made sense before the internet, but… c’mon now. Here’s how utilities should be done: live.sysinternals.com. 

If you end up downloading the entire (1.5GB!!!) AIK ISO but hate installing a bunch of junk just to use one thing, you can open the ISO in 7-zip and find the find the ImageX.exe file, by looking for F1_imagex in Neutral.cab, like so:

ImageX 

Then you can just extract that file and rename it to ImageX.exe.

Mod #2: Changing the VHD size

The wim2vhd script defaults to a 40GB dynamic disk. Normally, I don’t really care much about the size of a dynamic disk, because the actual size of the VHD is only as big as the actual used space, and you can compact a disk to recover space as needed. However, when you mount a dynamic drive, the boot manager and host filesystem appear to reserve the maximum possible size of the of the disk – 40GB. In my case (on a laptop), that wasn’t going to work.

It’s not just a convenience thing, either – if you have a VHD whose maximum size exceeds the physical disk space available, you’ll get a blue screen of death:

BSOD - Windows 7 Boot From VHD

(photo credit: Bart Lannoeye, see his post about the BSOD issue)

You can change the created VHD disk size using the /size parameter. For my Windows 7 + Visual Studio 2010 testing purposes, a 16GB disk seemed to work well. To do that, you’d call wim2vhd with this command:

cscript wim2vhd.wsf /wim:e:\sources\install.wim /sku:ultimate /size:16384

The size is calculated in MB, so you calculate it as 1024 * number of GB. A 20GB would use /size:20480

Mod #3: Rearming Windows to extend the evaluation time

If you’re using a virtual machine installation of Windows for temporary testing, you can use it without activation for 30 days. However, you can extend that evaluation period 3 times, giving you a total of 4 months, which is plenty of time for most evaluation purposes. It’s really simple:

Run "slmgr -rearm" from a command prompt with admin rights

This isn’t a hack – it uses a command that’s been shipped with Windows since Vista first came out. It’s not really news – Jeff Atwood wrote about it a while ago, and Ed Bott followed up with a cool tip on scripting that command to run every 30 days so you don’t forget. But it’s a really handy note, and it bears repeating.

Note: Apparently you can use the SkipRearm registry setting to extend that even further, but I don’t know if that’s covered by the EULA. I haven’t had the need to use a VM that long, so I’ve never run into that.

Mod #4 (untested): EasyBDC

You can apparently skip the rigmarole with BCDEDIT by using EasyBCD, because beta builds of EasyBCD 2.0 support the Windows 7’s VHD features.

Note: I haven’t done this. I’ve used previous releases of EasyBCD and haven’t had a problem, but I haven’t used EasyBCD 2.0 as it wasn’t out when I set up my VHD.

Mod #5 (untested): Disk2vhd

The SysInternals team recently released Disk2vhd, which can capture a disk image (while running) and create a VHD. I believe that in order to use the created VHD on the same machine it was created from, you’d first need to sysprep it, since otherwise you’re essentially trying to run two identical copies of the same operating system on the same computer, and you run into problems with drive paths. I haven’t tried this yet.

Gotcha #1: Go with Windows 7 Ultimate

Boot to VHD only works in Windows 7 Ultimate or Enterprise, not Windows 7 Professional. But you can’t use the Windows Activation re-arm trick we just talked about in Enterprise (since it uses a different licensing model). So I recommend that you go with Windows 7 Ultimate Edition.

Gotcha #2: Dual Boot means no hibernation

I use hibernation quite a bit, and only do a full reboot when I have to. So, for me, dual booting was inconvenient. It meant shutting everything down – including saving any tabs I happened to have open in IE8 (since tab saving in IE8 has been pretty unreliable for me) – in order to use the VHD partition, then shutting everything in the VHD partition down to switch back to the main one. That’s a lot of friction, and it ended up that I don’t use it as often as I thought I would.

As I write this, I’m setting up a VHD which I’ll just run under Virtual PC, because I can start it up without shutting everything else down. I still feel like it’s a great feature, just one that I’ll use less often than I thought.

Side note: Fast switching between boot instances would be a killer feature for Windows. I’d settle for multiple hibernation instances. I’ve read that it’s not enabled because of concerns over invalidating one hibernation instance while running the second machine instance, but I disagree – let me make that decision. At least give me a registry setting or something to enable it.

Published Sunday, October 25, 2009 3:57 PM by Jon Galloway

Comments

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

Gotcha #3 - if you are using BitLocker, you cannot boot to VHD with only one drive. :-(

Sunday, October 25, 2009 7:27 PM by timheuer

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

I agree about the fast switching option, that is really needed. I would also prefer multiple hibernation, this seems the best way.

Cheers,

Laurent

Monday, October 26, 2009 5:56 AM by Laurent Bugnion

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

I gave up on multi-boot long ago because inevitably the program I need to run is on the partition that is not currently active.  For now, VMs are the only solution that allows for launching any app, any time, regardless of which OS partition they are running on.

Monday, October 26, 2009 6:34 AM by jbrinkman

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

Your link to Scott's blog links to your internal mail server first.

Monday, October 26, 2009 10:56 AM by Roger

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

Roger - Thanks for pointing that out. Those sneak by me sometimes, because of course for me the link just works. Fixed.

Monday, October 26, 2009 12:59 PM by Jon Galloway

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

Great post Jon. Is it possible to boot a vhd both from disk and from VPC? (I guess it is not, from reading your post, but...)

Tuesday, October 27, 2009 12:53 PM by alberto

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

+1 for hibernation registry setting ;)

we NEED hibernation !!! NOW !

Friday, November 13, 2009 3:42 AM by Perica

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

Re Gotha#1, Dual Boot to Win7 VHD works for me on Win7 Professional.

I have retail copy of Win7 Professional (pre-ordered ont he cheap) and have successfully created a dual boot into a WIn7 Enterprise (as that is one of the VHD downloads available from MS).

I must admit, it took me a while but I had none of the issues you talk about.

Friday, November 27, 2009 3:52 PM by Stuart Wells

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

@Stewart Wells

Late comment... The limitation is in regard to the OS within the VHD container.  People using any edition can boot a copy of either Ultimate or Enterprise if those 2 are inside the VHD container.  Otherwise you will get a license restriction message upon bootup attempt.  Trust me I have already tried.

Saturday, January 16, 2010 1:50 AM by Robert

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

How much time does it take to boot from Windows 7?

Saturday, February 26, 2011 4:08 AM by tuition agency

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

Hey Jon, have you given up on this post? I mean just look at all the spam comments clogging it!

I've read a lot about vhd boot in Win 7 but not taken the plunge yet, myself. I guess, I'll try it now.

Actually, I was searching for the ultimate multiboot PE making tool available out there, since I recently started 'fixing' computers professionally - had been doing it for family and friends since 22 years because I had a job which I lost in the 'great crash' a couple of years ago

Saturday, September 1, 2012 4:05 AM by Trawler

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

ZeolRMUM  lfgzYXQvj  wffnrfmkfi  XKGpUwkoq sxoykv  MimHKEKVufk MjjpPWVR  ncxtLEYcy LvjpGYXV  apmsEMWbc

Wednesday, November 7, 2012 6:11 AM by whewerfelvish

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

MyveKLNT  pexmPIDnw  krjoxwxmaj  SGZjCtvnr tfwgqj  HmsZABOHqht AxdcBENE  uybvDHJgo ZlccCTFT  lrbpOHRhi

Thursday, November 8, 2012 10:09 PM by brilamuri

# re: My Boot-to-VHD experiment: found some tips, like it, but still haven’t found VM nirvana

DrktXCBX  bkgcQWYis  jaqpgsdtdc  GRYvJliht wmeveg  BagYNHMKqtx JsaqFELW  kheaCGJtm RrvwZHFA  rjaqVUKdw

Tuesday, November 13, 2012 9:08 PM by FexTureauro