Boot from a VHD in Windows 7 and Server 2008 R2

Windows 7 and Server 2008 R2 allow you to create a Virtual Hard Disk (VHD) that you can make bootable. This is particularly useful when needing to create a dual boot system and does not require having to partition your Hard Disk Drives (HDD).

First of all you will need to create the VHD. The easiest way to do this is to open Computer Management, expand the Storage node and select Disk Management.

Disk Management

Once in Disk Management, click on the arrow next to More Actions and select Create VHD.

Create VHD

When creating the VHD you are given a couple of choices regarding what type of VHD would you like to create and where would you like to have it created. I recommend choosing the Fixed Size option. Choosing this option will improve performance when compared to the Dynamically Expanding option. You can save the VHD anywhere.

VHD Creation

Once the VHD is created, you will need to Initialize it within Disk Management. This can be accomplished by right clicking on the unknown disk (new VHD) and selecting Initialize Disk. It the popup, accept the defaults and click OK.

Initialize Disk

Initialize Disk2

Once the VHD is initialized it needs to be formatted. This is accomplished by right clicking on the drive and selecting New Simple Volume. You can click through the wizard accepting the defaults. Ensuring that Quick Format is selected.

Format

Now that the VHD has been created and formatted, it needs to be prepped with an image. For this you will require the Windows Automated Installation Kit (WAIK) for Windows 7 from Microsoft. This can be downloaded at the following location:

http://www.microsoft.com/downloads/details.aspx?familyid=696DD665-9F76-4177-A811-39C26D3B3B34&displaylang=en

It is around 2GB in size and may take some time to download. Once downloaded you can burn it to a DVD or mount it by making use of a third party virtual CD-Rom software such as Deamon Tools lite or similar and then install WAIK using the default settings.

With the installation of WAIK completed, you can now move on to the next step which is creating the image on the VHD. You will need to open the Deployment Tools Command Prompt as an Administrator (right click Run as administrator). You will need to either mount the Windows 7 (Enterprise or Ultimate) media or insert the Windows 7 (Enterprise or Ultimate) DVD. Once done the following command will have to be run:

imagex /apply E:\sources\install.wim 1 G:\

Where E:\ is the Windows 7 Media and G:\ is the VHD that was created earlier (Your drive letters may differ). Option 1 that is selected specifies that the operating system being imaged is Enterprise Edition. Should you have Ultimate Edition the option would be 4.

WAIK

Once the command has finished running you need to detach the VHD. This is done by right click the VHD and selecting Detach VHD.

Detach VHD

Now that the VHD is prepped with an image all that remains is to edit the boot manager. In order to do this you will need to open an elevated command prompt (Run as administrator) and type the following commands:

bcdedit /copy {current} /d “Boot_from_VHD”

Copy the GUID that is displayed as you will require it for the rest of the commands.

bcdedit /set {GUID} device vhd=[C:]\test.vhd

bcdedit /set {GUID} osdevice vhd=[C:]\test.vhd

bcdedit /set {GUID} detecthal on

You can replace [C:]\test.vhd with the name and path of the VHD that you created.

BCDEdit

Once all the commands are done, you can reboot and will now have the option “Boot_from_VHD” available to you. You will have to boot into the VHD to complete the installation of Windows 7 that you setup earlier using WAIK.

Should you no longer wish to have the boot VHD, you can simply delete the VHD from your HDD and cleanup the boot manager. Use the following commands to cleanup the boot manager:

bcdedit

Copy the GUID of the entry that you wish to remove

bcdedit /delete {GUID} /cleanup

Congratulations, you have now created and configured a bootable VHD in Windows 7. The same procedure can be used for Server 2008 R2.

  • Peter Johnson

    Hi Andrew

    Very cool article which I will be using very soon as I want to try this on my laptop to build a lab.

Pin It on Pinterest