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:
- Adding a VHD drive to a Windows 7 computer
- Modifying the boot configuration to enable booting from either physical machine or VHD computer
- 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.
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.
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.
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.
Figure 4: Attach Virtual Hard Disk
The next screenshot shows the result. The VHD in this case is the E: drive.
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.
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"
Figure 7: BCDBoot on elevated command prompt
The next screenshot shows how the result should look like.
Figure 8: Boot files successfully created
Then reboot the computer and you will notice that there will be two boot options.
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"
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.
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}
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.