Search This Blog

Monday, July 25, 2011

Windows 7 Native Boot from VHD

When I bought my home computer (HP p6330f, Intel i3, 6GB RAM), I wiped the HDD and installed Windows 2008 R2 Enterprise Edition and set it up as a Hyper-V host. My main purpose of installing the server OS is to build a virtual lab environment to try different applications.

For fun staff (like checking e-mail, web sites, watching videos, writing blog articles....), I created Windows 7 VM. But as you know, virtual machines have hardware limitations like, USB device is recognized directly, audio and video driver compatibility issue. My Windows 7 VM doesn't have audio capability either.
The parent OS has also a known limitation in playing mov and mpeg4 format, so I decided to set up the PC so that it boots Windows 7 natively from VHD.
Now my Windows 7 can play audio & video and recognize USB devices natively.

The procedure is very simple but some points you should know.
You need a VHD installed Windows 7 Enterprise or Ultimate. (other editions of Windows 7 don't have this capability). You can create VM and copy a vhd file anywhere in your local drive but the disk must be basic not dynamic and formatted as NTFS.
A VHD can not be saved in a shared folder.

1. Start Command Prompt as an administrator

2. Type the following commands
BCDEDIT /copy {current} /d "Windows 7 (VHD)"
Windows 7 (VHD) is the name that will be listed when the machine boot, so you can choose any name you want.
The ID (9829fe28-ab1e-11e0-b6ba-d34fb3d32885) will be displayed. Use this ID for the next three commands

3. Type the following commands one line at a time.
BCDEDIT /set {9829fe28-ab1e-11e0-b6ba-d34fb3d32885} device vhd=[c:]\VMs\PC1.vhd
BCDEDIT /set {9829fe28-ab1e-11e0-b6ba-d34fb3d32885} osdevice vhd=[c:]\VMs\PC1.vhd
BCDEDIT /set {9829fe28-ab1e-11e0-b6ba-d34fb3d32885} detecthal on vhd=[c:]\VMs\PC1.vhd


[C:]\VMs\PC1.vhd is the path to the vhd file you want to use to boot. Do not miss "[" and "]". You will get an error.

After that you can review the change you just made to Boot Configuration.
Type BCDEDIT

4. Reboot PC
Once PC starts, 2 choices, Windows 2008 R2 and Windows 7 (VHD) will be displayed.
Select Windows 7.

In my case, Windows 7 didn't start and went to the next screen asking Start System Recovery or Windows 7 normally. The both options wouldn't work. Windows 7 didn't start because in my PC's BIOS settings SATA controller is set to AHCI while vhd is IDE.
I went into the BIOS settings and change the SATA controller from AHCI to IDE.
Now Windows 7 started as I expected.

5. When I boot to Windows 2008 R2, I had to change the SATA controller settings too. This   time I selected AHCI first but it didn't work (I don't know why). So I selected SCSI. 2008 R2 started.

When Windows 7 started, drivers will be installed and it will reboot again.
After reboot, type the following command.
BCDEDIT /deletevalue {9829fe28-ab1e-11e0-b6ba-d34fb3d32885} detecthal

No comments:

Post a Comment