Boot your machine from VHD

I posted a new guide on this blog: Click here…

Please read it before posting comments about other ways of doing this or mailing me with this information. In my new Guide things are done a little differently.

You might want to read this before starting to boot from "older" OS-s.

For the public beta (build 7000) read the last line first before trying to go step by step.

Last week at TechEd Barcelona, one of the coolest things we saw was the session from Mark Russinovich on the new stuff in Windows 7 and Windows Server 2008 R2, where he showed that with the new OS the boot mechanism allows for booting from vhd file. at that point I though: This is what I am going to try next week. and I did. I have it running now and in this blogpost I will try to write a step by step guide on how to set this up.

Before I do this, I have to say thanks to my colleague Martijn de Vries who did a lot of the preliminary work on this.

The whole story may start at two places: a running Vista install, in which case there is some preliminary work to be done by copying the dvd:bootmgr and bcdedit from the windows 7 DVD to your harddrive to enable this. BCDedit can also be downloaded here.

Furthermore you have to create a couple more steps: copy a vhd to a location on your harddrive (f.i. c:vhd) in Vista open an administrator Commandprompt and type:

BCDedit /copy {current} /d “temp” (this is just to get a repair option during the second part of the installation.)

Bcdedit /set <guid result of previous command> device vhd=[C:]vhdbestaandevhd.vhd

Bcdedit /set <guid result of previous command> osdevice vhd=[C:]vhdbestaandevhd.vhd

When you boot from the DVD, choose the temp option to do a repair for.

If you start like I did, with a running windows 7 machine, it is a pretty straight forward process.

first you boot from the DVD and instead of going through the complete setup you go to a repair process. and open a command prompt there.

On this command prompt you do the following:

Open Diskpart.

on the diskpart prompt you type:

create vdisk file=c:vhdwin7server.vhd type=fixed maximum=15000&#160; (this will create a new (empty) vhd file from a fixed size of 15000 MB in the existing path c:vhd)

Select vdisk file=c:vhdwin7server.vhd (this command will set the focus of diskpart to the newly created Virtual disk.)

Surface vdisk (this “mounts” the virtual disk so it is available.)

Exit

On the command prompt type SETUP

This will restart the installation of the OS you were installing (windows 7 or Windows Server 2008 R2.) now you can point the installation to begin at the just created VHD file.

The above is true for the PDC build(build 680xx),

For Build 7000 ( the public eta, where is says surface, read Attach. Thanks Bas and Cesar for pointing this out to me.)