Problem solve Get help with specific problems with your technologies, process and projects.

Windows 7 Boot-from-VHD feature creates mobile Hyper-V labs

With the Windows 7 Boot-from-VHD feature, you can eliminate disk chunking turn desktops and laptops into mobile Hyper-V labs.

Sometimes, dual-booting operating systems really stinks. While dual-booting enables multiple OSes to run on a single machine, it breaks apart contiguous drive space into lots of little chunks. One way to circumvent this problem is through the new Windows 7 Boot-from-VHD capability. In this tip, we explore how to use Windows 7 Boot from VHD to eliminate the problem of disk chunking and how to turn desktops or laptops into virtual labs.

Normally, disk chunking -- the multiple and segregated volumes that must be created for each to dual-boot -- isn't a big problem. Nowadays, disk drives are large, and most desktops and even laptops don't need all of their available space. This situation changes somewhat when you create a Hyper-V lab on your machine, however.

Consider the situation in which you've divided a machine into two halves: one for Windows 7 and another for Windows Server 2008 R2. It's beneficial to occasionally boot into Windows Server 2008 R2 to tinker around with Hyper-V in a nonproduction lab environment. In doing so, you've probably discovered that Hyper-V's large-sized Virtual Hard Disks (VHDs) take up available disk space quickly.

This disk space shortage is exacerbated in a dual-booting configuration. The reduced size of each volume means that they fill up faster, forcing you to spread VHDs all around your configured disks. The result is a smattering of VHDs across multiple partitions and disks, eliminating any reasonable attempt at storing Hyper-V's virtual machines (VMs) in a single, easy-to-remember location.

With Windows 7 as your primary system, however, you can configure the boot menu to power on that desktop or laptop from any number of local VHDs. Better yet, because VHDs can be configured to grow as necessary, it becomes possible to store a larger quantity of lab-use servers on a single laptop.

Here are the steps to add a new VHD:

    1. From a system running Windows 7, open the Disk Management console. This can be done either through Server Manager or through the diskmgmt.msc command line tool.

    1. Within Disk Management's Action Menu, click Create VHD. In the resulting dialog box, provide a location for that VHD on the local hard drive as well as a size. To conserve space, set the Virtual Hard Disk format to dynamically expanding.

    1. Selecting OK creates the VHD and makes it appear in the Disk Management console. Next, right-click the attached disk once to initialize it and again to create/quick format a new simple volume.

    1. Once the disk is created and formatted, it is ready for an OS installation. Insert the Windows Server 2008 R2 DVD into the computer's optical drive and reboot. Navigate through the installation steps until you've reached the target disk installation screen.

    1. At this point, note that only the computer's physical drives are available in the selection box. You'll need to attach your VHD to the Windows Preinstallation Environment (WinPE) before continuing. To do so, launch WinPE's command prompt with the Shift+F10 key sequence. At the command prompt, enter DiskPart to launch the disk partitioning utility. Then, enter Select vdisk File={pathToVHD}, followed by Attach vdisk.

  1. Next, close the command prompt and navigate back to the installation graphical user interface. Once there, refresh the disk view. You should now see the newly attached disk available in the list. Select this disk (disregarding error messages that appear), and continue with the installation.

After the installation is complete, reboot the computer again. Also, note the boot selection menu. There should be a new selection for your Windows 7 Boot-from-VHD R2 instance.

One caveat about this configuration involves the amount of available disk space on your desktop or laptop. When creating new VHDs using the steps above, be conscious of VHD size. While a dynamically-expanding VHD may appear to consume only a few gigabytes when it is dormant, it requires its maximum disk space size allotment during the boot process. This means, for example, that 20 GB of free disk space must be available on the desktop or laptop when the VHD is booted.

Nevertheless, I've found this new method for booting multiple OSes superior to the old way, for of the following reasons:

  • VHD files are more portable. VHDs that are created on one desktop or laptop can be transported to another similarly configured machine. Connecting them requires some boot-menu customization using the Bcdedit command-line tool, though.
  • VHDs can be easily offloaded. VHD files can be moved from a desktop or laptop to an external file server or USB drive if you need to rearrange space or make more space available. VHDs can also be copied, moved and used as OS templates, in the same manner as VMs.

In the end, using the Windows 7 Boot-from-VHD feature enables you to quickly create and tear down a Hyper-V lab, without the nastiness of dual-boot configurations.

Greg Shields

Greg Shields is an independent author, instructor, Microsoft MVP and IT consultant based in Denver. He is a co-founder of Concentrated Technology LLC and has nearly 15 years of experience in IT architecture and enterprise administration. Shields specializes in Microsoft administration, systems management and monitoring, and virtualization. He is the author of several books, including Windows Server 2008: What's New/What's Changed, available from Sapien Press.

Dig Deeper on Virtual server backup and storage

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.