How to add a Windows 7 Virtual Hard Disk to a physical Windows 7 machine and make it dual boot

by Klaus Graefensteiner 25. January 2010 08:21

Overview

You will find several blog posts on the internet that cover this topic, but this one will not skip any seemingly unimportant detail. In fact I tried out some of the tutorials and added the steps that I thought were missing.

Note: The following procedure assumes that you already have a bootable VHD hard drive.

I  picked two machine names that I am going to use during this step-by-step tutorial:

  • Physical Machine: Boots from real physical disk partition: “Kreutzotter7
  • VHD Machine: Boots from VHD file that resides on physical partition: “Copra7

The tutorial explains the following procedures:

  1. Adding a VHD drive to a Windows 7 computer
  2. Modifying the boot configuration to enable booting from either physical machine or VHD computer
  3. Restoring a VHD computer by overwriting the vhd file.

Adding a VHD drive to a Windows 7 computer

First boot into your physical Windows 7 computer and create a folder for your vhd files.

Create folder c:\vhds.

CreateFolderVhds

Figure 1: Create a folder called Vhds

Then copy copra7.vhd into c:\vhds. Copra7.vhd is a virtual hard disk file that we created in an earlier step. I am going to write a blog post about this procedure as well.

CopyCopra7VHDIntoVHDsFolder

Figure 2: Copy existing vhd file with Windows 7 installed into this folder

Open Disk Management and attach copra7.vhd. Go to your Computer icon and select the right mouse click menu “Manage”. This will open the Computer Management tool. Navigate to the Storage/Disk Management node.

DiskManagementBeforeVHD

Figure 3: Go to Disk Management

Click the menu option Action/Attach Virtual Hard Disk. Browse to the vhd file that you just copied into the c:\vhds folder a, select it and hit the OK button.

AttachVHD

Figure 4: Attach Virtual Hard Disk

The next screenshot shows the result. The VHD in this case is the E: drive.

AttachedVHDInDiskManager

Figure 5: Virtual Disk is now attached

Change the drive letter from e: to x:. To do this click on the e: volume in the volume list and select the right mouse click menu option “Change Drive Letter and Paths…”. Select the x: drive letter.

ChangedDriveLetter

Figure 6: Drive letter changed to x:

Configure boot options for dual boot

Now run a cmd command prompt as Administrator. On this elevated command prompt type:

bcdedit /set description "Windows 7 VHD Sandbox"

BCDBoot

Figure 7: BCDBoot on elevated command prompt

The next screenshot shows how the result should look like.

BCDBootSuccess

Figure 8: Boot files successfully created

Then reboot the computer and you will notice that there will be two boot options.

DualBootWithTwoWindows7Options 

Figure 9: Dual boot entries with two Windows 7 options. Boot into the first (default)

Reboot into first Windows 7 option (default vhd). This is our VHD computer “Copra7”. On elevated command prompt type: 

bcdedit /set description "Windows 7 VHD Sandbox"

BCDEditOnCopra7ToChangeDescription

Figure 10: Change the boot description while being in “Copra7”

Now reboot into second Windows 7 not default and now the only one actually called "Windows 7". This is “Kreutzotter7” our physical computer.

DSC00028 

Figure 11: Boot into the “Kreutzotter7” machine with is not yet the default boot selection

On elevated command prompt (Run cmd as Administrator) type:

bcdedit /default {current}

SetKreuzotter7DefaultBootOption

Figure 12: Make the current boot option the default one

Now the computer will by default boot into the old Windows7 OS that boots form the physical partition.

Restore VHD image and reset the OS

This is the easiest step. Just boot into the Windows 7 OS that is installed on the physical disk. In my case this computer is called Kreutzotter7. Now you can backup and restore the vhd file copra7.vhd as you wish. To restore the sandbox VHD, just boot into Kreutzotter7 and replace the copra7.vhd file from a backup.
Then reboot into Copra7. Which is the boot option with “Sandbox” in its name.

That’s it.

Tags: , , ,

Tips & Tricks | Test Automation | Virtualization

Comments are closed

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 2012, 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 2012 by Klaus Graefensteiner

Rendertime:
Page rendered at 2/4/2012 5:11:10 AM (PST Pacific Standard Time UTC DST -7)