Introduction
This is the third blog post about Microsoft Windows VHDs (Virtual hard disks) on Windows 7. In the first two articles I described how to Create a Windows 7 VHDand how to configure Windows 7 so it would dual-boot from the physical and the new virtual hard disk.
This tutorial provides easy to follow steps for copying a VHD file to a Windows 7 computer and modify the boot manager to allow the booting from the VHD. In my case I created the VHD file on a DELL Latitude D830 and wanted to use it on my Acer Aspire 1420 P (The PDC 09 laptop). Because both host computers run on completely different hardware, the boot loader configuration needs to account for letting the HAL (Hardware Abstraction Layer) do its job to reconfigure and install hardware drivers during the first boot.
Figure 1: Booting from VHD on new hardware (Acer Aspire 1420 P) for the first time will swap the drivers
Let’s get started
First boot normally into Windows 7 from a physical hard drive. Then copy the vhd file on that hard drive. In my case I copied it in the following folder C:\vhds\copra7.vhd.
Figure 2: Copy the vhd file
Next backup the boot configuration. To do that run the following command:
bcdedit /export c:\bcdbackup
Figure 3: Backup your boot configuration
No create a copy of your current boot configuration. Current means the operating system that you just booted into. This is the Windows 7 OS from the physical hard disk. Run the following command:
bcdedit /copy {current} /d “Windows 7 VHD Sandbox”
“Windows 7 VHD Sandbox” is the name of the boot menu entry in my example. You can of course call this entry what ever you want.
Figure 4: Copy the current boot menu entry
Next copy the GUID including the curly braces from the console output into your clip board. Your GUID will be different. In my case the GUID is:
{cc6d12fb-abec-11df-9e68-a5f110fc4bbc}
You will need this GUID for the next three commands. Run the following three commands to hook up the new boot entry. Use the path of your vhd file as device vhd and osdevice vhd parameter value.
bcdedit /set {cc6d12fb-abec-11df-9e68-a5f110fc4bbc} device vhd=[c:]\vhds\copra7.vhd
bcdedit /set {cc6d12fb-abec-11df-9e68-a5f110fc4bbc} osdevice vhd=[c:]\vhds\copra7.vhd
bcdedit /set {cc6d12fb-abec-11df-9e68-a5f110fc4bbc} detecthal on
Figure 5: Hooking up the new boot entry
Before you reboot and enjoy the new boot entry you can verify the changes using the following command:
bcdedit /v
Figure 6: Listing the boot entries
Resources
The following two resources are helpful:
Add a Native-Boot Virtual Hard Disk to the Boot Menu
Adding a native boot VHD to Windows 7
Ausblick
Virtualization Galore! I am now wondering whether you can boot from a Hyper-V VHD in the same way. I will give it a try. I just downloaded the VisualStudio 2010 Lab Management Evaluation VHD. Let’s see how that works.