Hyper-V, Booting and Ghosting/Imageing computer

Virtual Machines can be a joy to play with but sometimes a real hassle to set up, especially if you use your “good ol” ghosting program for several computers (for example in a lab setup) and perhaps have chosen to boot from a virtual machine.

First problem:
After ghosting, boot record can not be found.

Something like “missing MBR” (master boot record that is), “operating system not found” and similar heart stabbing messages can sometimes be fixed with this procedure.

Boot from installation disk and get into “Repair”
Go to the prompt and type
Bcdboot “c:\windows”

and that’s it. (Your windows installation on c: needs to be ok of course.)

Second problem:
Hyper-V is available but you cannot start your virtual machines.

Well, the the above code added the basic booting “code” but removed the booting “code” for activating Hyper-V.
So open the command prompt and type
bcdedit /set hypervisorlaunchtype auto

and off you go.

A couple of things good to know as well:
Sometimes the virtual machines wont start because the files are read-only.
HAL detection is sometimes also present in  the boot “code” and removed on bcdboot command. To add this go to the command prompt and type: bcdedit /set detecthal yes


Booting Hyper-V

You can boot directly from a virtual machine with Hyper-V (server 2012).

Go to (for example):
Server Manager -> Tools -> Computer Management
Storage -> Right Click Disk Management -> Attach VHD and choose the vhd you want to use.

After attaching a vhd, start the command prompt as administrator and type:

Bcdboot <driveletter for vhd-disk>:\windows
(makes the vhd available for booting, example: bcdboot h:\windows )

Bcdedit /set {default} Description <name for booting the vhd>
(makes the vhd boot as default and adds a description, example: bcdedit /set {default} Description VirtualServer2012Data)

If you want to remove the boot option type:
Bcdedit /delete {default}

Some good links to bcdboot and bcdedit: