How to boot from a VHD on Windows 7

by Klaus Graefensteiner 24. August 2010 10:00

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.

HAL

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.

Create folder and copy VHD file

Figure 2: Copy the vhd file

Next backup the boot configuration. To do that run the following command:

bcdedit /export c:\bcdbackup

Backup BCD store

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.

Copy host boot entry for VHD with its own description

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

Running BCD setup commands with new GUID

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 

List new boot entry

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.

Tags: , , , , ,

Tips & Tricks | Virtualization | Windows 7

About Klaus Graefensteiner

I like the programming of machines.

Add to Google Reader or Homepage

LinkedIn FacebookTwitter View Klaus Graefensteiner's profile on Technorati
Klaus Graefensteiner

Klaus Graefensteiner
works as Developer In Test and is founder of the PowerShell Unit Testing Framework PSUnit. More...

Open Source Projects

PSUnit is a Unit Testing framwork for PowerShell. It is designed for simplicity and hosted by Codeplex.
BlogShell is The tool for lazy developers who like to automate the composition of blog content during the writing of a blog post. It is hosted by CodePlex.

Administration

About

Powered by:
BlogEngine.Net
Version: 1.6.1.0

License:
Creative Commons License

Copyright:
© Copyright 2013, Klaus Graefensteiner.

Disclaimer:
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Theme design:
This blog theme was designed and is copyrighted 2013 by Klaus Graefensteiner

Rendertime:
Page rendered at 5/22/2013 8:51:37 AM (PST Pacific Standard Time UTC DST -7)