次の方法で共有


Windows VHD Goodness

If you're at all into the many goodies that Windows 7--and it's bigger sibling, Windows Server 2008 R2--is delivering, you will probably have heard about the ability to boot to VHD files. If you haven't heard this, you should know a few things before reading the rest of this post:

  1. A VHD file is a Virtual Hard Drive used by MS Virtual PC and MS Hyper-V.
  2. Hyper-V is the new Virtual Machine platform included with Windows Server 2008 R2 (although it's actuallly been around a little bit longer than that, but that is irrelevant to this article.)
  3. As alluded to in item #1, a VHD represents the Hard Drive of a virtual machine; the actual VM is represented by a series of other files. This means that it is possible--as with a physical hard drive--to connect/disconnect/reconnect a single VHD to a variety of different virtual machines.
  4. Starting with Windows 7 and Windows Server 2008 R2, it is possible to boot directly to a VHD.

It is point #4 that I am concerned with for this post.

"So what?", you ask.

Well, I'm not going to answer that. That question has already been answered several times, in a number of really good posts, including this one by Scott Hanselman (make sure to read the comments between Scott and Bryan Likes), and this one by Daniel Bucherer. In addition to answering the question of "So what?", these posts also do a great job of detailing how to get set up; so I won't be going into that, either.

What I will do, however, is provide some of the links I've been using, as well as some caveats I've discovered.

First, the links:

There are plenty of other posts--both blog and technical articles--covering the subject, but these are the links I found most helpful.

Now for the caveats:

  • I've seen it mentioned elsewhere, but only in passing so it bears mentioning here: You must make sure that the physical drive hosting your VHD has enough empty space to accomodate the maximum size of your VHD. With a VHD, you can set the maximum size to which the drive is allowed to grow. If the host media (generally a physical disk drive, although some have also figured out how to host a VHD on a USB flash drive) doesn't have enough space to accomodate the maximum (i.e. not just the current size) of the VHD, attempting to boot to the file will fail.

  • With Hyper-V, the recommended practice is to host VMs and their corresponding VHDs on a separate spindle (i.e. a separate physical drive, in most instances) from the one that holds the host OS. The reason for this is performance. If you also want to be able to boot from a VHD hosted thus, make sure that the physical drive is noted as a bootable drive in your computer's BIOS.

    For instance: I have two hard drives in my laptop.

    • The first is a 90Gb drive that came with the machine. Currently, it hosts the base operating system: I installed Windows Server 2008 R2.
    • In my life as a SharePoint consultant, I was constantly running VMs outfitted with SharePoint and Visual Studio in order to do SharePoint development work. Since I get better performance if I run my VMs on a separate spindle, I replaced the DVD drive with a second hard drive (using an adapter for my Lenovo T61p). This hard drive is 300Gb--plenty big to hold a number of VMs and their corresponding VHDs.
    • There are times when it is beneficial to be able to boot directly to one of the VHDs on which I'm developing new SharePoint code (e.g. when heads-down, working on a large, build-time- and run-time-intensive project.)
    • In order to boot from one of these VHDs, I had to change my BIOS settings so that the secondary hard drive was included on the list of boot devices. Otherwise, I get an error.
  • Be very clear: the boot-to-VHD capability is not available for booting to a VHD installed with any operating system other than Windows 7 or Window Server 2008 R2. For anyone wanting to boot to a VHD running Linux, or even an earlier version of Windows, it is not possible at this time. And so that no one gets their hopes up unnecessarily, I know of no plans to make this abililty possible on any other OS, either. This means that, for all of my customers hosting SharePoint on Windows Server 2003, I will unfortunately not be able to leverage this technology when developing for their environments.

  • Setting up the BCD (Boot Configuration Data) store is, while not exactly difficult, probably not for the faint-of-heart. My personal beef with the configuration/setup portion is the lack of useful error messages when the configuration doesn't work. As with all new tech, be prepared for some frustration. On the other hand, unless you know what you're doing--and are truely interested in doing it--you probably won't be interested in getting set up for boot-from-VHD anyway.

So go ahead and give it a try!