How to Create a Boot VHD Step By Step

Friday, January 1, 2010
Windows 7 and Windows Server 2008 R2 allow you to create a bootable VHD (virtual hard disk) with its own operating system (also called Native Boot).  This is really useful when you need to run another operating system or platform on the same hardware.
Note: Native Boot is limited to the following operating systems: Windows 7 Enterprise (x86 or x64), Windows 7 Ultimate (x86 or x64), and Windows Server 2008 R2.
For example, my Dell workstation normally runs Windows 7 Ultimate x64.  I wanted to update the BIOS from Dell's support site, but the BIOS installer won't run in x64 operating systems.  I also wanted to update the firmware on my Parrot Minikit Slim bluetooth car kit, but the USB driver for the P5+ USB Stage1 device is only available for x86 computers.

In previous versions of Windows, the solution would be to make a dual-boot system.  The problem with this is that you and Windows will need to contend with similarly named folders (i.e., \Windows and \Program Files).  A bootable VHD is a discreet virtual disk that contains it's own OS.  The single VHD file can reside on your normal disk drive (for example, C: or D:), or even a USB drive.  The VHD will contain its own file structure, but you can still access the physical drives, folders and devices on the parent computer.

The walkthrough I'm documenting here will create a bootable VHD file that runs Windows 7 Enterprise x86.  Let's get started.

 Creating the VHD Drive
  • First, start up and login to the parent operating system (in my case, Windows 7 Ultimate x64).
  • Open Computer Management in Administrative Tools
  • Expand Storage and click Disk Management. You will see your normal physical drives.
  • Right-click Disk Management and select Create VHD
  • Enter the file path and name, size, and format for the VHD as show below:
  • Here, I'm creating a 20GB dynamically expanding VHD named D:\Win7x86.vhd.  A dynamic disk will start off very small (~42KB) and will grow as data is written to it, up to the maximum size specified (20GB).  Microsoft has made huge improvements in the performance of dynamic VHDs in Windows 7 and Windows Server 2008 R2, so they perform nearly the same as fixed size disks.
  • Click OK to create and mount the VHD volume.  The new disk will be listed in the bottom pane of the Disk Management console as an Unknown Disk.
  • Right-click the Unknown Disk and select Initialize Disk, as shown here:
  • Click OK to initialize the disk with an MBR partition.
  • Now right-click the Unallocated disk and create a New Simple Volume.  The New Simple Volume Wizard will run.  Assign the new volume as drive X:, give it the volume name, Win7x86, and quick format it with the NTFS file system.  The new volume will be displayed in Disk Management and the D:\Win7x86.vhd file will grow to about 77MB.
You now have a new 20GB virtual hard disk, drive X:  Next, we will prepare the disk to install Windows 7 Enterprise x86.

Preparing the VHD for the New Operating System
  • First, you need to download and install the Windows Automated Installation Kit (WAIK) for Windows 7 from Microsoft.  Be aware that this is a 1.7GB ISO and can take some time to download.  Burn the ISO to a DVD or mount it using virtual CD-ROM software like UltraISO, PowerISO, etc., and then install WAIK.
  • Open a CMD prompt as Administrator and change to the %SystemDrive%\Program Files\Windows AIK\Tools\ folder.  In my case, this is C:\Program Files\Windows AIK\Tools\amd64.
  • Mount the Windows 7 Enterprise Edition x86 media.  In my case, this is on the DVD drive E:
  • Run the following command to prepare drive X: for the new operating system:

imagex /apply E:\sources\install.wim 1 X:\
  • Imagex will apply the Windows 7 binaries to the VHD drive X:  The 1 specifies that the operating system is Enterprise Edition.  The application will begin, as shown below:
  • Imagex application normally takes about 7-8 minutes, despite what the progress bar shows.  When it completes, you will see several new folders on drive X:
  • Now you need to detach the VHD disk.  In Disk Management, right-click the VHD disk and select Detach VHD, as shown below:
  • You will notice that the D:\Win7x86.vhd file has grown to about 5.5GB.
We now have a VHD with the Windows 7 Enterprise x86 files installed on it.  We need to configure the computer so that it can boot to the VHD and complete the installation of Windows 7.

Adding the VHD to the Boot Menu
  •  Open an elevated CMD prompt and enter the following command:

bcdedit /copy {current} /d "Windows 7 Enterprise x86"
  • This will return the GUID of the Loader Object that you will use to replace in the following commands:
bcdedit /set device vhd=[driveletter:]\vhdpath\vhdfilename

bcdedit /set osdevice vhd=[driveletter:]\vhdpath\vhdfilename

bcdedit /set detectHAL on

The detectHAL command is used to force Windows to auto-detect the hardware abstraction layer. The commands I used are shown below:

Completing the Installation

Now we are ready to boot from the VHD. When you restart the computer you will see a new entry in the boot menu for Windows 7 Enterprise x86, along with the default Windows 7 or Windows Server 2008 R2 option.

Restart the computer and select the new Windows 7 Enterprise x86 option to complete the installation of Windows 7. The first time the new OS starts, the install process will install needed device drivers and restart the computer. The second time your start the OS, miniprep process will walk you through configuring the user name, password, computer name, and the network settings.

Congratulations! You have completed the boot to VHD process.