Saturday, May 2, 2009

Converting Windows 7 boot from VHD to be VM under Hyper-V or any Virtualization boots VHD

When you install Windows 7 on your machine but not directly to your hard disk but to a VHD file in your physical disks

I have created article named Boot your physical machine from a VHD file describing the installation process.

In some cases you may want to take this VHD and to make it running inside Virtual Machine in Microsoft Hyper-V or Microsoft Virtual Server.

There is some simple facts you have to know about boot from VHD

    1. The windows is fully installed in the first partition on the VHD.
    2. When your machine restarts the boot files are launched from the physical disk.
    3. Next, the VHD is mounted and an entry in the Boot Configuration Data configuration loads the winload.exe

VM where the VHD is mounted will not boot and it will display the screen below; this means the partitions is not marked as active

image

to make the VM bootable it will take two main steps:

First, step is to make the Partition bootable

Second, we have to install the BCD in the active partition

To complete these steps.

I will boot the VM with Windows 7 DVD.

image

image

image

image

image

Click next to proceed in the repairing process.

image

Click Repair your computer.

image

Press next after finish searching

image

Select Command Prompt

image

image

image

Type in command prompt the following

Diskpart

then select the disk and the windows partition and mark the partition as active

Select disk 0

select partition 1

active

exit

image

image

To restore the boot configuration data type the below commands.

Bootrec.exe /FixMbr

Bootrec.exe /FixBoot

Bootrec.exe /RebuildBcd

the final part is copy the boot manager files to the VHD boot partition.

Change directory to Drive D:\ where the Windows 7 DVD is mounted by type

image

d:

copy bootmgr c:\

copy bootmgr.efi c:\

Now, you can start the VM and it will Windows 7 will boot correctly correctly.