I'm loving the Windows 7 "Boot to VHD" lifestyle. This isn't Virtual Machines, to be clear, and it's not Dual Booting. It's Boot to VHD.

Let me break it down:

Method Pros Cons Dual Booting Your OS's always run at full speed. You can screw up your partition table. You have to partition which means disks of fixed size. Or you can have them all share the same disk, which is dangerous.

OS's aren't portable. Virtual Machines Your OS's are completely separate from each other and can't hurt one other. Your OS's are very portable. You get Undo support for your disks. Everything is virtualized, so you're taking a perf hit on pretty much everything. Often not a good solution for laptops. Boot to VHD Your OS runs on the hardware directly, except your disk, which is virtualized and runs inside a single file. Estimated 3%-5% perf hit. Seriously. Also is awesome on a laptop if you have the HD space. None! But I'm biased! Neener neener!



Only works on internal drives or ESATA. No USB Drive support. No undo disk support.

Making a VHD is easy with Windows 7 since you can create and mount/attach VHDs in the standard tools. VHD as a disk format is built into the Operating System (although, strangely, you can't mount ISOs.).

You can create a blank VHD, set it up in your boot menu with BCDEdit (details and walkthrough here and a video demo here) and then just boot off your VHD. If you want to install your OS (Windows Server 2008 and Win 7 Enterprise or Ultimate are the only ones supported) then you just install away.

However, this is STILL not convenient enough for me.

I'm always trying crazy new Daily Builds of big stuff that takes a while to be installed. The step where I install an OS onto my VHD takes too long, so I'd like a prepared VHD that's already to be started for the first time, kind of like when you buy a machine from Dell or whoever and you get that nice "starting your computer, detecting drivers" action on first boot.

Well, there's a script over at the MSDN Code Gallery to help with this. It's the Windows Image to Virtual Hard Disk Converter (WIM2VHD).

From their description:

The Windows(R) Image to Virtual Hard Disk (WIM2VHD) command-line tool allows you to create sysprepped VHD images from any Windows 7 installation source. VHDs created by WIM2VHD will boot directly to the Out Of Box Experience, ready for your first-use customizations. You can also automate the OOBE by supplying your own unattend.xml file, making the possibilities limitless.



Fresh squeezed, organically grown, free-range VHDs - just like Mom used to make - that work with Virtual PC, Virtual Server, Microsoft Hyper-V, and Windows 7's new Native VHD-Boot functionality!

I like this guy already.

How to SysPrep your Windows 7 Image

I copied my Windows 7 DVD to a folder on a drive with lots of space free. I probably didn't need to copy it over, but it likely made the process faster.

Then I downloaded and installed the Windows® Automated Installation Kit (AIK) for Windows® 7. This file is a large ISO (1.5G) so be aware. It's meant for admins, not humans. I didn't want to burn the ISO to disk, so I used 7-Zip to open the ISO as an archive and extract it. (If you're not using 7-Zip, you're missing out on life, BTW)

Now, go into C:\Program Files\Windows AIK\Tools and find ImageX.exe and copy it where you put the Windows Image to Virtual Hard Disk Converter (WIM2VHD) script.

Go read the Example Command Lines for Win2VHD, but since I had a Windows 7 Ultimate I ran this command-line. Note that d:\win7working is where I copied my DVD.

cscript wim2vhd.wsf /wim:d:\win7working\sources\install.wim /sku:ultimate

In this example, d:\win7working is the folder I copied the DVD to. Could be your DVD drive too, I suppose.

It chewed for a while, maybe seven minutes. You'll also here the "Device Plugged In" sound as the script automatically connects a VHD as a drive temporarily so don't panic:

D:\>cscript wim2vhd.wsf /wim:d:\win7working\sources\install.wim /sku:ultimate

Microsoft (R) Windows Script Host Version 5.8

Copyright (C) Microsoft Corporation. All rights reserved.



Windows(R) Image to Virtual Hard Disk (WIM2VHD) Converter

Copyright (C) Microsoft Corporation. All rights reserved.

Version 6.1.7100.2



Check for updates at http://code.msdn.microsoft.com/wim2vhd!



MACHINE INFO:

Build=7600

Platform=amd64fre

OS=Windows 7 Ultimate

ServicePack=

Version=6.1

BuildLab=win7_rtm

BuildDate=090713-1255

Language=en-US



INFO: Looking for IMAGEX.EXE...

INFO: Looking for BCDBOOT.EXE...

INFO: Session key is E765F413-44E9-4F9B-AEA5-DBC8A726F7A6

INFO: Inspecting the WIM...

INFO: Configuring and formatting the VHD...

INFO: Applying the WIM...

[ 100% ] Applying progress

INFO: Making the VHD bootable with BCDBoot...

INFO: Unmounting the VHD...

Summary: Errors: 0, Warnings: 0, Successes: 1

INFO: Done.

Magical. Now I've got a 5 gig VHD file that I can setup to boot from directly as described here. The first time I start up, it'll be 95% into the setup process and just ready to detect my hardware. It's a nice "OEM-like" VHD that I can use again and again.

Since I'm only using these VHDs temporarily (for a week or two for testing) I won't use an activation key and instead leave that field blank during setup. That'll buy me 30 days of testing if I need to, and I can easily start over by just starting over with my new fresh VHD.

Enjoy! Now go tell Mike and his team that they're awesome. Go ahead. I'll wait here.

Related Links