Add a Native-Boot Virtual Hard Disk to the Boot Menu

Published: October 22, 2009

Updated: October 22, 2009

Applies To: Windows 7, Windows Server 2008 R2

The following procedures describe how to add a native-boot virtual hard disk (VHD) to the boot menu using the BCDedit tool. If you are adding the VHD to a computer that already has a Windows® 7 installation, you will need to add a boot entry to the menu. If you are adding the VHD to a computer running an older version of Windows, for example Windows Server® 2008, you will need to update the system partition using the BCDboot tool and then edit the boot menu using the BCDedit tool.

To update a BIOS-based computer to include a Windows 7 boot menu

If you are deploying the VHD to a BIOS-based computer without a Windows 7 boot menu, for example, a computer using Windows Server 2008 as the running operating system, you will need to update the boot environment using a Windows Preinstallation Environment (Windows PE) disk before you can configure the system for native-boot VHDs.

  1. Copy the .vhd file to the destination computer. For example, at a command prompt, type:

    copy N:\VHDs\windows7.vhd C:
  2. Use the DiskPart tool in Windows PE to attach the VHD on the destination computer. You can attach a VHD by using the Attach vdisk command. This activates the VHD so that it appears on the host as a disk drive rather than as a .vhd file. At a command prompt, type:

    diskpart
    select vdisk file=c:\windows7.vhd
    attach vdisk
    list volume
    select volume <volume_number_of_attached_VHD>
    assign letter=v
    exit
  3. Use the BCDboot tool, located in the \System32 directory of the VHD image or in Windows PE to copy the boot environment files and Boot Configuration Data (BCD) configuration from the \Windows directory in the VHD to the system partition. On a computer with BIOS firmware, the system partition is the active partition of the first hard disk. For example, to use BCDboot from the VHD image, at a command prompt, type:

    cd v:\windows\system32
    bcdboot v:\windows

The BCDboot tool automatically imports information from the existing installation when updating the BCD. The computer is now updated to include a Windows 7 boot environment. You can now follow the steps in the section "To add a native-boot VHD to an existing Windows 7 boot menu" later in this topic.

To update a UEFI-based computer to include a Windows 7 boot menu

If you are deploying the VHD to a UEFI-based computer without a Windows 7 boot menu, for example, a computer using Windows Server 2008 as the running operating system, you will need to update the boot environment using a Windows PE disk before you can configure the system for use with native-boot VHDs.

  1. Copy the .vhd file to the destination computer. For example, at a command prompt, type:

    copy N:\VHDs\windows7.vhd C:
  2. Use the DiskPart tool in Windows PE to attach the VHD on the destination computer. You can attach a VHD by using the Attach vdisk command. This activates the VHD so that it appears on the host as a disk drive rather than as a .vhd file. At a command prompt, type:

    diskpart
    select vdisk file=C:\windows7.vhd
    attach vdisk
    list volume
    select volume <volume_number_of_attached_VHD>
    assign letter=v
    exit
    
  3. On a UEFI-based computer, the system partition is hidden by default and must be assigned a drive letter before running the BCDboot tool. Use the DiskPart tool to locate the EFI system partition and assign it a drive letter. At a command prompt, type:

    diskpart
    select disk 0
    list partition
    select partition <x>
    assign letter=s
    exit
    
    Where <x> is the 100 megabyte (MB) EFI system partition formatted with FAT.

  4. Use the BCDboot tool, located in the \System32 directory of the VHD image or in Windows PE to copy the boot environment files and BCD configuration from the \Windows directory in the VHD to the system partition. For example, to use BCDboot from the VHD image, at a command prompt, type:

    cd v:\windows\system32
    bcdboot v:\windows /s s:

The BCDboot tool automatically imports information from the existing installation when updating the BCD. The computer is now updated with a Windows 7 boot environment. You can now follow the steps to add a native-boot VHD to an existing Windows 7 boot menu.

To add a native-boot VHD to an existing Windows 7 boot menu

If you are deploying the VHD to a computer with an existing Windows 7 or Windows Server® 2008 R2 installation, you can use the BCDedit tool to make the new VHD bootable and add it to the boot menu. For more information about using the BCDedit tool, see this Microsoft Web site.

noteNote
Before you begin, you can back up your BCD store using the BCDedit tool with the /export option. For example, at a command prompt, type: bcdedit /export c:\bcdbackup

  1. Copy an existing boot entry for a Windows 7 installation. You will then modify the copy for use as the VHD boot entry. At a command prompt, type:

    bcdedit /copy {default} /d "vhd boot (locate)"
    When the BCDedit command completes successfully, it returns a {GUID} as output in the Command Prompt window.

  2. Locate the {GUID} in the command-prompt output for the previous command. Copy the GUID, including the braces, to use in the following steps.

  3. Set the device and osdevice options for the VHD boot entry. At a command prompt, type:

    bcdedit /set {guid} device vhd=[locate]\windows7.vhd
    bcdedit /set {guid} osdevice vhd=[locate]\windows7.vhd
  4. Set the boot entry for the VHD as the default boot entry. When the computer restarts, the boot menu will display all of the Windows installations on the computer and boot into the VHD after the operating-system selection countdown completes. At a command prompt, type:

    bcdedit /default {guid}
  5. Some x86-based systems require a boot configuration option for the kernel in order to detect certain hardware information and successfully native-boot from a VHD. At a command prompt, type:

    bcdedit /set {guid} detecthal on

See Also

Tags :


Community Content

Stanley Roark
[locate] should be defined somewhere within this article.
<p>Step 3 under "To add a native-boot VHD to an existing Windows 7 boot menu" needs to better define [locate].<br /><br /> bcdedit /set {guid} device vhd=[locate]\windows7.vhd<br /> bcdedit /set {guid} osdevice vhd=[locate]\windows7.vhd<br /><br /><br /> [locate] should be the drive where the VHD exists. If this was on the C drive for Instance, the commands would look like the following:<br /><br /> bcdedit /set {guid} device vhd=[C:]\windows7.vhd<br /> bcdedit /set {guid} osdevice vhd=[C:]\windows7.vhd<br /><br /> Trying to determine what [locate] was lead me to numerious syntax errors for bcdedit, I needed to look elsewhere to get the proper syntax.<br /><br /> Kind regards.</p>
Tags :

Willamet
[locate]
Using [locate] instead of a drive letter in square brackets acts like a wild card for a drive. Literally, the boot loader scans all detected volumes looking for that particular path. This feature is useful since the default drive letter assignments can be difficult to predict. <div><br /></div><div>Experimentally I can see it scan all my attached drives when I use it. If you have identical paths on two volumes it will find one of them first in a deterministic fashion, but its hard to say what that volume will be until you see it the first time. If you are distributing VHDs down to random unknown machines, I recommend using a guild as part of the path for each deployment. </div><div><br /></div><div><br /></div>
Tags :

mjeddian
Read the MS-DOS manual Microsoft.
<span> <pre>cd v:\windows\system32 bcdboot v:\windows</pre> </span> <br />I'm used to seeing this mystical usage of "cd x:\.." in other guides, but I would expect better of the company that "wrote" MS-DOS.<br /><br />Changing the active directory of V: does absolute nothing in this context. This would make sense:<br /><br /><span><pre>cd v:\windows\system32 v:bcdboot v:\windows</pre></span><br />as would this:<br /><br /><span><pre> v:\windows\system32\bcdboot v:\windows</pre></span><br />Or even this:<br /><br /><span><pre>v:<br />cd \windows\system32 bcdboot v:\windows</pre></span><br />And from reading other (non-microsoft) guides on bcdboot, I know that these three examples (which all do exactly the same thing) is the correct procedure. Although it only becomes relevant if the OS version on the VHD is different to the one you booted from.<br />
Tags :

Prototyped
The [locate] confusion
[locate] the literal string is actually valid (and in fact necessary for BCD's on removable media). What I'm not sure of is whether it can be used generally, or whether it's only valid for Windows PE on removable media.
Tags :

Scott Schindler
Edit the original document or replace it.
The information contained above regarding {locate} is imperative to following a step by step process. People do not read the whole document before follwoing the step by step process. It was obvious that locate would imply the loctaion of the file, however it should be edited directly to prevent frustration and failure for the tech following this process. Having this information as additional content is now enough, but appreciated.
Tags :

Page view tracker