Skip navigation

Creating Bootable VHDs with Disk2VHD

Boot a physical system from a system drive stored as a VHD—a capability that you might find very handy

This month, I'd like to start covering a few tools that enable a feature in Windows 7 and Windows Server 2008 R2 that could be quite significant: the ability to boot a physical system not from the physical C drive (as we're used to) but from a system drive stored as a virtual hard disk (VHD). This particular column is a little unusual, however, because typically when I introduce a tool to solve a problem, you already understand the nature of that problem. But booting from a VHD is a new concept, so I’ll start by explaining it, then I'll introduce this month's tool—Disk2VHD.

Why would you want to boot a physical system from a VHD? I can think of several reasons, but two important reasons relate to ease of OS deployment. First, consider how you get an OS onto a server or workstation in the first place. You can install the system manually by popping the installation DVD into the system's drive, booting it, and answering a lot of questions; you could use the installation DVD and simplify the process with an unattended installation script; or you could use one of the many available imaging tools to take a pre-built OS image and blast it onto a new system’s empty hard disk. Imaging is usually the fastest of the three options, but how do you accomplish that imaging?

Symantec Ghost is probably the best-known commercial tool, and Microsoft offers a free alternative called ImageX, but in both cases the imaging process is fairly opaque. If something goes wrong during the image transfer, it can be difficult to determine the cause. In contrast, booting from VHD essentially requires that you copy a specially prepared VHD file onto the target system’s hard disk. So, booting from VHD offers what might be called XCOPY deployment.

The second reason is ease of virtual machine (VM) deployment. By creating and maintaining your system images as VHDs—rather than, say, as Ghost GHO files or ImageX WIM files—you can quickly deploy (i.e., copy) those VHD-format images to physical systems or as new, quickly built VMs under a Hyper-V server by simply copying the VHDs to the Hyper-V server and creating a new VM around the VHD. Microsoft has even made VHDs a bit more attractive as deployment tools by including VHD support in Server 2008 R2's Windows Deployment Services (WDS) servers.

To create a system that boots from a VHD, you need to accomplish several steps. First, you need a VHD file that contains a bootable, generalized image based on a Windows 7 or Server 2008 R2 system. (If you’re unfamiliar with the term generalized, it’s just Microsoft's latest word for "Sysprep-prepared.") Second, you’ll need a VHD that contains an image of a bootable Windows drive. Acquiring a VHD to that specification requires that you create an empty VHD file (which I've covered in previous months), grab a bootable system, use Sysprep to prepare it, boot it with an OS (probably WinPE), then use ImageX /capture to convert that working system to a WIM file. Then, you'd have to select and mount the VHD file as some drive letter and use ImageX again (this time with /apply) to deploy that image to the VHD. At that point, you're done, and you can distribute the VHD to new VMs or physical systems that will boot from that VHD.

Now, that process is a fairly tall order, and I’ll show you how to do those things in the coming months. But our friends at Sysinternals offer some instant gratification with a free tool called Disk2VHD. Disk2VHD takes drives on running systems and converts them to one or more VHDs—no ImageX, no WinPE, no Sysprep—all thanks to the Volume Shadow Copy Service (VSS). Its syntax is simple:

disk2vhd <drive>|* <vhdfilename>

So, for example,

disk2vhd C: E:\a.vhd

would create a VHD from drive C, and

disk2vhd * E:\a.vhd

would copy all volumes—even Window 7's unlettered volume—to a VHD file. Alternatively, just start up Disk2VHD to get a GUI. Even if you specify more than one volume, Disk2VHD packs them up into one VHD.

Now, that'll work in very specific situations, but not in most cases, as simply creating an image and handing identical copies of that image out to zillions of machines can cause some trouble security-wise. For non-trivial deployments, however, we'll need to make the images generic with Sysprep, and next month, we'll see how to make Sysprep work—and that will get us a bit closer to making boot-from-VHD work.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.