Last month, in "Creating a Bootable VHD" (InstantDoc ID 129194), I gathered all the concepts necessary to create a bootable VHD. This month, I'll again draw from past Windows Power Tools pieces to deliver a big “wax on/wax off” moment: booting a Windows 7 Enterprise or Ultimate system from a VHD. (Sorry, Windows 7 Professional, Windows Vista, and Windows XP folks—only Enterprise/Ultimate can do this.)

Two primary concepts are at the heart of boot-from-VHD. First, instead of the typical route of booting from a C volume stored on a physical drive (physical drive chopped up into volumes, volumes get names like C, and you then install an OS onto C, leaving tens of thousands of files on C), you first create not a physical hard drive but a virtual one in Microsoft’s VHD format and store it as a file with a name such as image.vhd. You then mount image.vhd as a drive letter (e.g., H), install a copy of Windows onto it (in ways I've discussed in the past few months), and end up with an entire Windows boot drive—but a boot drive all neatly tied up in the one image.vhd file. Second, you copy that VHD file onto some computer that's already running Windows and configure the already-extant copy of Windows to allow the system to alternatively boot from the VHD—not the C: drive.

(Why would you want to do this? If you store system images as VHDs, they can serve two deployment scenarios. In the first, you deploy desktops to people as virtual machines—VMs—running on large Hyper-V servers, and as you might know, VHD is Hyper-V’s native virtual disk format. In the second, you distribute a desired desktop image to physical desktops, but instead of needing a special-purpose imaging tool such as Ghost, Clonezilla, or ImageX, your deployment tool is Windows Explorer—just drag and drop the VHD file.)

So, the first part is easy: Just copy image.vhd to somewhere on the target machine. For this example, I’ll assume you've copied image.vhd to a folder named C:\images. Now, all you've got to do is tell the existing copy of Windows how to allow the new alternative VHD-packaged copy to boot. To accomplish that, you’ll have to refer to two columns—“Bcdedit Basics” (InstantDoc ID 101168) and “Booting Up with Bcdedit” (InstantDoc ID 101362)—that discuss the command-line tool for controlling how Windows boots.

As those articles specify, you’ll need to create a separate “OS entry” with Bcdedit before you can configure Windows Boot Manager to offer the option at boot time to boot from image.vhd (as well as booting the old way, from C). You can call the new OS entry “Boot from VHD”:

bcdedit /copy \\{current\\} /d “Boot from VHD”

That gives you the OS entry’s new GUID:

The entry was successfully copied to \\{61bed0dc-ddd7-11df-9094-70f3954a3108\\}.

Now you have to set two boot parameters in \\{61bed0dc-ddd7-11df-9094-70f3954a3108\\}: “device” and “osdevice,” setting their values to “vhd=\\[driveletter:\\]\vhdfilespec.” Thus, as you're booting from C:\images\image.vhd, you’d type these instructions:

bcdedit /set \\{61bed0dc-ddd7-11df-9094-70f3954a3108\\} device vhd=\\[c:\\]\images\images.vhd<br>bcdedit /set \\{61bed0dc-ddd7-11df-9094-70f3954a3108\\} osdevice vhd=\\[c:\\]\images\images.vhd

Those are ugly commands, but you can see from the examples how to construct them: Bcdedit /set, followed by whatever GUID you got, then either device or osdevice (you need two commands, one for each), then the vhd=… section.

Set those up, reboot your system, and you’ll see the Boot Manager and two options: Windows 7, which you’ve been using so far, and Boot from VHD. Choose the latter, and you’re running from a VHD!

Still wondering how you might use this capability? If you need a tool to let you roll back a physical system—say, a classroom computer—as you can with a commercial product such as DeepFreeze or with Microsoft’s late and lamented SteadyState, then let me suggest that you go back and read “Diskpart Takes Snapshots of Physical and Virtual Systems” (InstantDoc ID 125233), wherein I talked about how to create child/parent pairs of VHD files that could provide the snapshot capability so popular in virtual machines, and suggested that it might be quite useful in virtual machines. I’ll show you how to set that up, and talk about a nice (and free) tool called Wioski that implements the concept, next month.