website statistics
Boot your machine from VHD - Eric Denekamp - blog community
blog community
Boot your machine from VHD
Eric Denekamp

Blog Search Form

Go

Syndication

Widgetbox Widget

News

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:]\vhd\bestaandevhd.vhd

Bcdedit /set <guid result of previous command> osdevice vhd=[C:]\vhd\bestaandevhd.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:\vhd\win7server.vhd type=fixed maximum=15000  (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:\vhd\win7server.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.)


Posted 12-11-2008 11:49 by Eric Denekamp

Comments

lotacus wrote re: Boot your machine from VHD
on 16-11-2008 1:11

That's fine and dandy for those who want to mount future Windows Operating systems, but what about legacy OS' like windows XP or Windows Vista?

I am thinking that the boot manager itself has the capability of mounting the vdisk and if that's correct, then mounting any pre-existing Virtual Disks you have with an Operating system installed on it, would start that operating system?

Have you tried mounting a Windows Vista VHD using bcedit and seeing if it will boot? Or a Windows XP?

I have been trying for some time to get it right, but no luck thus far. When your in the host operating system (Windows 7) can you run bcedit and post what the entries are to give me an idea of where I may be going wrong?

Eric Denekamp wrote re: Boot your machine from VHD
on 16-11-2008 8:38

Of course I can post my entries, I have not tried to boot a lagacy OS yet. ( i did not have time for that, ihope I have time for it next week. Below are my boot entries ( from a normel bcdedit /enum. if you like maore, mail me directly and I'll send you more info.

Windows Boot Manager

--------------------

identifier              {bootmgr}

device                  partition=\Device\HarddiskVolume1

path                    \bootmgr

description             Windows Boot Manager

locale                  en-US

inherit                 {globalsettings}

default                 {current}

resumeobject            {6d158159-adcc-11dd-8a9d-9d3c90479382}

displayorder            {current}

                       {6d15816b-adcc-11dd-8a9d-9d3c90479382}

                       {6d15816c-adcc-11dd-8a9d-9d3c90479382}

toolsdisplayorder       {memdiag}

timeout                 15

Windows Boot Loader

-------------------

identifier              {current}

device                  partition=C:

path                    \Windows\system32\winload.exe

description             Microsoft Windows 7

locale                  en-US

inherit                 {bootloadersettings}

recoverysequence        {6d15815b-adcc-11dd-8a9d-9d3c90479382}

recoveryenabled         Yes

osdevice                partition=C:

systemroot              \Windows

resumeobject            {6d158159-adcc-11dd-8a9d-9d3c90479382}

nx                      OptIn

Windows Boot Loader

-------------------

identifier              {6d15816b-adcc-11dd-8a9d-9d3c90479382}

device                  file=[C:]\vhd\2k8toy.vhd

path                    \Windows\system32\winload.exe

description             Server 2008 R2 toy

osdevice                file=[C:]\vhd\2k8toy.vhd

systemroot              \Windows

resumeobject            {70878617-b140-11dd-a15a-806e6f6e6963}

Windows Boot Loader

-------------------

identifier              {6d15816c-adcc-11dd-8a9d-9d3c90479382}

device                  file=[C:]\vhd\2k8boot.vhd

path                    \Windows\system32\winload.exe

description             Server 2008 R2 Demo

osdevice                file=[C:]\vhd\2k8boot.vhd

systemroot              \Windows

resumeobject            {03702d56-b142-11dd-9219-806e6f6e6963}

I have two vhd boots: both a server 2008 R2, one for demo purposes and one to ploay around with and maybe wreck and try again.

lotacus wrote re: Boot your machine from VHD
on 26-11-2008 6:01

ok great! thanks. well looking at the vhd entries, it seems that everything I had was correct, the only difference though, was the identifier it is using. It seems that it is using the same identifier for all the entries including your host machine, where my vhd identifiers were different from the host OS. Maybe that is where i went wrong, or perhaps using an identifier of {legacy}, which *should* tell the bootmanager that the VHD contains a legacy bootmanager.

but then  when it comes to the following:

path                    \Windows\system32\winload.exe

systemroot              \Windows

I am confused if that is pointing to the physical disk or to the file / directory within the VHD.

McAkins wrote re: Boot your machine from VHD
on 27-11-2008 10:16

Hi Dennis,

Nice write-up, pretty appreciated. But you were a little vague on how to copy the bootloaders from the Windows 7 DVD to the local drive and activate them for an existing Vista install.

For example I copied the files as you wrote above, renamed the old C:\bootmgr and C:\Windows\System32\bcdedit.exe to *_old; copied the Win7 bootmgr to C:\ and the bcdedit.exe to the system32 folder.

On running the new bcdedit (ver 6.1) got the error that the version of bcd editor will not work on the current OS (freely quoted here of course).

It seems to therefore that your solution could only work in a Windows 7(ver 6.1) installed environment instead of the Vista(ver 6.0) environment. Or do you have another angle to solving this problem. Thanks for your information.

McAkins wrote re: Boot your machine from VHD
on 27-11-2008 10:19

Message truncated above:

On running the new bcdedit (ver 6.1) got the error that the version of bcd editor will not work on the current OS (freely quoted here of course). Rebooting did not solve the problem

It seems to therefore that your solution could only work in a Windows 7(ver 6.1) installed environment instead of the Vista(ver 6.0) environment. Or do you have another angle to solving this problem. Thanks for your information.

McAkins wrote re: Boot your machine from VHD
on 27-11-2008 11:04

Much to my embarrasment, discovered I got your name all wrong, should have written Eric instead of Dennis, very sloppy of me. My sincere appologies.

Exotic Hadron wrote re: Boot your machine from VHD
on 13-12-2008 22:20

Hello, Eric!

Nice news. I was thinking about attaching the Hyper-V or Virtual Server's VHDs to my test Windows Server 2008 R2 system setup. The reason is, I don't plan to include the R2 machine into the production environment. However, I would like to test some real-life application that I am running there in R2 environment.

What would be the proper command to do that and include the VHD entry into the boot menu?

I tried the follwowing command.

bcdedit /create /d "Windows Testbed" /application osloader /inherit device /device vhd=[d:]\vhd\customenv.vhd

but all that to no avail.

What am I doing wrong? The VHD file contains a boot partition with opearating system and my custom applications.

Thank you.

Eric Denekamp wrote re: Boot your machine from VHD
on 18-12-2008 9:52

What I did to get this running, is copy the current boot entry to a new one, and edit that one, I did not create a new one from scratch... very important too is that when you create the vhd, that you surface it after that... if you forget this, (afaik) it will not boot from it, and only be available for any virtual machien tool.

good luck

lotacus wrote re: Boot your machine from VHD
on 22-12-2008 7:27

I'm still not clear on how useful this vhd stuff is. To make use of it you would need to start with Windows 7 so you can create VHD's. Operating systems before windows 7 do not recognize vhds, so one could not install the os' to these. So there's no benefit in that. I've seldomly used Virtual PC so I dont know if VHD's are created with it when installing virtual operating systems, so there's also no benefit in having windows xp/vista/server VHD's. Lets say VPC makes vhds from Virtual Operating system installs, well that's time well wasted installing the os in a vpc, then complicatingly modifying the boot loader by hand to recognize the VHD as a bootable operating system.

So at least in my eye's, it's wasted time, complicated with very little benefit. Especially if this were incorporated or "sold" as a business/corporate feature.

What about an arugument about Operating system portability because it's a VHD? Well that can be thrown out the window as well, until there is a dynamic boot loader, a dynamic device manager (like Linux live disks) or VHD booting capability within the bios, it will be impossible to hook up an external hard drive to a PC and boot a VHD without touch the files and disk on that particular computer.

Unless there is something i'm missing, I just cannot see the value in this feature they implimented.

Eric Denekamp wrote re: Boot your machine from VHD
on 22-12-2008 7:44

Lotacus, I agree with you about the "lack" of usability NOW, but if NOW were the only argument ever, there would not have been progress in any subject. I see the advantage for the future, I agree that more OS-s might need to adapt to this way of working, but at least Now I can have portability of my system without using an underlying platform that eats my resources without any use except for playing the host.

I should say, give it some time. I am happy with it for I can now use it to play around with multiple OS's on my laptop without creating multiboots and multiple partitions. and if I muck up, the cleaning up is easy to do.

Merry christmas to you all and a happy new Year.

mcakins wrote re: Boot your machine from VHD
on 27-12-2008 17:44

Hi Eric,

Do you have an angle for resolving the issue I mentioned above? Thanks already.

Bas Steelooper wrote re: Boot your machine from VHD
on 10-01-2009 18:25

Hello Eric,

I found the following problems:

- Surface is not working ==> BCDEdit gives the following alternative: ATTACH      - Attaches a virtual disk file.

When I Attach the VHD and try to install I receive the error that installing to VHD is not supported.

Trying to install: Windows 7 Enterprise Edition Build 7000

Have you tried this?

Regards,

Bas Steelooper

Cesar de la Torre wrote re: Boot your machine from VHD
on 11-01-2009 18:07

Bas, it works with Windows 7 Enterprise Edition Build 7000.

You are right, you have to use 'Attach' instead of 'surface'.

I got similar error than you, but than you just need to create a partition and format it. Than you can install it. It properly worked for me using Windows 7 Enterprise Edition Build 7000.

Cesar de la Torre

Eric Denekamp wrote re: Boot your machine from VHD
on 11-01-2009 21:04

Hi Guys, I did not have time to test this against build 7000, I will do so tomorrow. and I'll keep you posted.

Roel Janssens wrote re: Boot your machine from VHD
on 13-01-2009 16:34

Eric,

In your instruction you say:

Bcdedit /set {GUID} device vhd=[C:]\vhd\2k8toy.vhd

Bcdedit /set {GUID} osdevice vhd=[C:]\vhd\2k8toy.vhd

In your bcd-dump it says:

device file=[C:]\vhd\2k8toy.vhd

osdevice file=[C:]\vhd\2k8toy.vhd

Notice the difference between the word after device & osdevice (file vs vhd)

When I use 'vhd' the Boot Manager gives me an error when I start the machine regarding some invalid information in the Boot Configuration Data store.

When I use 'file' Windows 7 start from the vhd, but after 20 seconds I get a BSOD with error 0x0000012F and the message "An initialization failure occured while attempting to boot from VHD"

Martin Born wrote re: Boot your machine from VHD
on 15-01-2009 13:39

It seems that the "repair"-option is only available for drives that are not protected by BitLocker. Mine is. What can I do to "repair" the temp settings?

Jim wrote re: Boot your machine from VHD
on 15-01-2009 22:32

Eric, you say "at least Now I can have portability of my system", but that's not really true is it?  Since it's booting the VHD now rather than running it virtualized, you require all of the unique hardware drivers in the VHD now as opposed to just the VM enlightenments don't you?

When the VHD isn't being booted, the virtualized hardware works, and is what enables the portability, but when you boot it, it's no longer portable as best I can surmise.

Eric Denekamp wrote re: Boot your machine from VHD
on 16-01-2009 7:56

for me the protability consists of have a multiboot and backing up my system (Laptop) without a lot of hastle, and I am able to run a newer version next to the old version, be able to figure out the stability and when proven stable, I can delete the old version.

But in general, you are right, you cannot move my vhd from one piece of hardware to a complete other piece of hardware without the hastle of reinstalling all kinds of drivers.

But in your datacenter, if you have standardized hardware, you machines will be portable: just pick up the vhd move it to another machine and it WILL run without that hastle.

Jordan wrote re: Boot your machine from VHD
on 20-01-2009 6:45

Good article.

Has anyone figured out how to get a legacy OS to boot off a VHD?

I know you can't INSTALL to a VHD from a legacy, but I have been experimenting with pre-existing VHD's that I made up in Virtual PC.

For instance, I have a pre-existing VHD with XP on it, but I can't seem to get it to boot using the above BCDEDIT method. I suppose it has something to do with the boot loader methods, as XP uses "\ntloader", and Windows 7 seems to use "\Windows\system32\winload.exe"

See right now, I am dualbooting XP and Windows 7 from seperate drives, and when I look at the entry for XP I see this:

Windows Legacy OS Loader

------------------------

identifier              {466f5a88-0af2-4f76-9038-095b170dc21c}

device                  partition=E:

path                    \ntldr

description             Earlier Version of Windows

Most likely it's ignorance on my part, as I have not played around with the bootmanager in Vista at all, so I don't know a lot of the commands. I just can't seem to figure out how to get my XP VHD to have similar settings though.

So I imagine it WOULD be possible to boot from a VHD with XP (or any other legacy OS for that matter) wouldn't it?

______________________________________________________________

As far as the usefulness goes, once the technology gets honed out, this could actually change the dynamics of partitioning. Think about it, if you want to set up a beta OS, or even check out a linux distro and only have one hard drive, but it's plenty big, then you just use a VHD. As it stands, the OS takes up the whole hard drive unless you partition in advanced. Or you have to use an extra program to play around with the partition setup like Partition Magic.

IMO simply booting from a VHD can simplify all this. Granted the process of setting up a bootable VHD needs to be simplified, but this is just in the making.

Eric Denekamp wrote re: Boot your machine from VHD
on 20-01-2009 7:49

I agree with you on your partitioning standpoint, I am very curious on how other and legacy OS-es will proceed in supporting this. AFAIK when trying to boot from VHD, the OS loader needs a driver to open the VHD and then gives the rest to the booting OS, this needs drivers to boot further. XP does not support this. the VHD is a filesystem now, it is not an emulated or other "HARD DRIVE" I do not think that now other OS-ES than windows 7 and Windows server 2008 R2 will be able to boot from VHD. this may come for vista and Windows server 2008 in a future Service pack.

Other vendors I am not sure that they will support booting from VHD very soon.

Roel Janssens wrote re: Boot your machine from VHD
on 22-01-2009 11:20

I fixed the BSOD by creating a fixed size vhd instead of the (default) dynamically expanding vhd.

Was type=fixed always in your manual? If so, why did I skip that part?

Eric Denekamp wrote re: Boot your machine from VHD
on 22-01-2009 11:36

It has always been there, although I have experienced the expandable option to be working from build 7000. In the previous build it only worked with fixed vdisks, a differential disk did not work either. I have not tried that yet, but afaik that should work now too.

Roel Janssens wrote re: Boot your machine from VHD
on 25-01-2009 12:25

Yesterday night I discovered a quicker/easier way to accomplish a VHD-boot.

Later in the evening I read a thread somewhere that confirmed my findings.

----------------------------------------------------------------------------------------

Boot your machine from the Windows 7 DVD/USB

At the install screen press Shift-F10 to get a command prompt

Type 'dir' to see which drive letters are assigend and where your vhd should go

diskpart

create vdisk file=c:\vhd\win7.vhd type=fixed maximum=40000

select vdisk file=c:\vhd\win7.vhd

attach vdisk

exit

setup

----------------------------------------------------------------------------------------

So no need to create a boot entry before starting the installation and no need for cleaning up the boot configuration database afterwards.

Eric Denekamp wrote re: Boot your machine from VHD
on 25-01-2009 12:57

I think this is only possible:

a) from build 7000 and

b) when not installing next to Vista, but on a windows 7 install,

I think i will go try this in two weeks when I am goint to rebuild my machine, ( this all depends on the app-V client and its compatibility with windows 7. and the time I have to create the streams of all my applications...

Roel Janssens wrote re: Boot your machine from VHD
on 27-01-2009 23:45

Eric (and those that also think all the above is cool stuff), on the Microsoft forums I've posted a solution to also boot from a differencing disk:

http://social.technet.microsoft.com/Forums/en-US/winserverhyperv/thread/c7189892-ba70-4348-a952-79c50317ecc9

Have fun rebuilding your machine, let us know when (and how) the project is finished ;-)

Larry wrote re: Boot your machine from VHD
on 05-02-2009 11:18

Can anyone move the vhd file to an external drive and boot from there?

Syed Mehroz Alam wrote re: Boot your machine from VHD
on 05-02-2009 18:29

Very nice post, I was successfully able to boot from a Windows Server 2008 VHD using this approach. I, then tried to boot my XP vhd but could not succeed. For this, I made a copy of my existing WinXP option in and changed "device partition=C:\" to "device vhd=[E:]\myxp.vhd". It, however, loads my real XP when I select this WinXP VHD boot option. Is it possible?

Eric Denekamp wrote re: Boot your machine from VHD
on 06-02-2009 7:49

Syed and others trying this, be aware that this feature needs both support from your boot mechanism, AND the OS you are booting... This means, if it was not supported in the OS you are trying to boot, it will not work when using the bootmanager from Windows 7. The bootmanager only opens up the VHD file and points to the file necessary to proceed booting. If that file does not have knowledge on how to handle VHD files natively, it will fail.

Roel Janssens wrote re: Boot your machine from VHD
on 06-02-2009 9:23

Larry, I tried booting from a vhd placed on an external USB-HDD, but I didn't succeed. I can remember reading somewhere that for now booting is only supported on internal fixed disks.

Eric Denekamp wrote re: Boot your machine from VHD
on 06-02-2009 9:32

I might add to that, that this also depends on the moment the external drive is recognized. I can imagine, ( I have not tried this, ) that If I boot from that external drive, that you will be able to boot from VHD on that same Disk.

I can imagine that the boot manager being on the internal dis, it is a delicate process of booting to something not native, that somewhere inside the boot process you might lose connection to the external drive because of a driver load or something else.

Just my two cents.

Joao wrote re: Boot your machine from VHD
on 07-02-2009 14:38

I successfully Installed Windows 7 build 7000 in a VHD file

along side my XP x64 installation

XP was already installed

I booted from the Windows 7 DVD

opened a CMD prompt

created and mounted a fixed VHD

Installed Windows 7 to it.

Now I'm wondering what if I tried the same time with Vista x64... would it work?

Or what if with 2 DVD drives, one with Windows 7, the other with Vista

I boot from the Windows 7 DVD, create an other VHD the same way I did before

and then instead of starting Windows7 Setup... I strated Vista's setup....

would that work?

I'll be trying this later tonight....

Adam wrote re: Boot your machine from VHD
on 24-08-2009 23:18

Thankyou, My computer goes very slow when running win 7 in vpc so that is a GOOOOOD idea

matt wrote re: Boot your machine from VHD
on 10-11-2009 22:25

To those interested in creating native VHDs on systems such as Windows XP, Windows Server 2003, Windows Vista, etc...Take a look at this utility. This takes all the work out of setting up a dual-boot VHD environment and manages it as well.

www.portlock.com/.../leap_frog

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Enter code (required)
Powered by Community Server (Commercial Edition), by Telligent Systems