Keith Combs' Blahg

Ramblings from another nerd on the grid

Dual Boot from VHD Using Windows 7 and Windows Server 2008 R2

Dual Boot from VHD Using Windows 7 and Windows Server 2008 R2

  • Comments 36
  • Likes


Executive Summary

Boot from VHD is a new technique for installing and maintaining operating system environments.  Unlike virtual machines, the operating system that is running from a “boot from VHD” environment is using the actual hardware instead of emulated hardware.  This means a developer could easily use WPF and the full GPU processing power of a high end graphics card.  In another scenario, this technology makes it easy to setup and run Windows Server 2008 R2 with the Hyper-V role, thus supporting 64 bit virtualization workloads.

The Virtual Hard Disk (VHD) is the container for the installed operating system.  Because everything is inside a single file, there are a number of benefits that can be realized for data center server environments, as well as managed desktop environments.  The following article dives into the technical details of implementing two operating systems.  Both are installed in a VHD file and can easily be booted by selecting the preferred environment at power on.  This could easily be scripted and automated.

The Installation Foundation – Windows PE

The Windows Preinstallation Environment (WinPE) has been updated for Windows 7 and Windows Server 2008 R2.  One of those improvements is the ability to use a Virtual Hard Disk (VHD) file as the target for an installation of the operating system (OS).

This has some interesting implications.  Booting from a .VHD file that contains an entire OS seems rather magical.  I mean think about it.  You go to look at a hard drive and there’s a single file but Windows Server 2008 R2 is installed inside it.  This would certainly simplify the ability to boot your servers on a completely new environment with little effort.  This is going to turn change management on its ear.

The same is true for the desktop OS, Windows 7.  You can install Windows 7 inside a .VHD file.  Again, the OS is installed inside a single file and thus makes it rather easy to move or change out and bring up a completely different version of the environment.  This will make test environments for developers super easy to construct and test discrete sets of applications or components.

One thing that is not well known is how easy it is to create the initial .VHD file and install the operating system into it.  The supported and documented ways are geared towards very well defined support scenarios.  You can see the supported scenarios in the Windows Automated Installation Kit (WAIK).  Most people have been reluctant to take the time to learn this because it involves the use of imagex captures and applies.

What if you could install with just the DVD?

You can.  All you need is a hard drive with disk space and the DVD for Windows 7 RC or Windows Server 2008 R2 RC.  In fact, when I was investigating the tools for this article I used a brand spanking new Hitachi 2.5” 320GB 7200rpm hard drive and both DVDs to create a dual boot environment.  Nothing more.  And it’s much simpler than I thought.  The key is WinPE and DISKPART.  Here is the screencast demonstration of the tools in action.

The Screencast Video – 23 minutes – Win7 and R2 Dual Boot via VHD

Get Microsoft Silverlight

The Command Sequence Used in the Video

  1. Boot your machine with a blank hard drive using the Windows 7 DVD.
  2. Click next on the language screen if English is appropriate.
  3. SHIFT+F10 to launch a WinPE command console.  Although the commands below are in upper case, the commands are not case sensitive.  I am only using upper case for readability here.
  4. Enter DISKPART to run the utility.
  5. LIST DISK to see the available disks in your system.  I am assuming a single raw disk.
  6. SEL DISK 0
  10. ASSIGN
  11. LIST VOL
  12. CREATE VDISK FILE=c:\windows7rc.vhd MAXIMUM=200000 TYPE=EXPANDABLE
  13. SELECT VDISK FILE=c:\windows7rc.vhd
  18. LIST VOL
  20. exit DISPART
  21. exit WinPE command console
  22. Install to the newly created 200GB (fuzzy math) virtual hard disk which looks just like a partition to Windows Setup
  23. Repeat steps 11-18 for the Windows Server 2008 R2 VHD but with the obvious changes for the vdisk filename, size, etc.

Other References and Articles

Windows Automated Installation Kit (WAIK) for Windows 7 and Windows Server 2008 R2 RC – get it @  This is the bible for the supported methods of using “Boot from VHD”. 

Windows Virtualization Blog – see their VHD boot post at  Particularly interesting is the performance area of the post.

Knom’s Developer Corner – another nice post at

So What’s Next ???

Tomorrow I am going to backup my existing Windows 7 production hard drive.  Windows 7 is installed in the traditional fashion on a 200GB drive right now.  I am going to restore the backup to a larger disk then install Windows Server 2008 R2 RC into a .VHD and test mixing them.  That’s a bit of a hybrid and one I think a lot of developers might be interested in.  It would certainly demonstrate you can have a traditional implementation of your production OS, but flip to any other Windows Server 2008 R2 or Windows 7 testbed very easily.  I’ll follow-up here or another post when I get that implemented.  Enjoy.

[UPDATE for 5/23/2009] As I indicated just above, I wanted to run an extension of the test I recorded.  I backed up my 200GB Windows 7 RC environment then restored it to a 320GB drive.  After that, I booted from the Windows Server 2008 R2 RC DVD and created a bootable VHD with R2 inside.  The VHD is stored in a folder at the root of my 320GB disk.  The R2 setup program fixed up the bcdstore area and I now have a dual boot hybrid.  Windows 7 is installed in the traditional manner.  R2 is booting from the VHD.  Both are available on the selection menu at power up. Interesting stuff for sure.

[UPDATE for 5/25/2009] Since I received a couple of questions out of band on how I captured the demo, let me explain.  The demo was captured using Camtasia v6.0.2.  The demo was a Hyper-V virtual machine, not native hardware.  I had mentioned that in some of the preliminary takes but I guess I didn't make that clear in the final take.  Therefore, the booted OS in the screencast is actually using the emulated hardware of the virtual machine.  Everything you see in the demo works on my native hardware, a Lenovo ThinkPad T61p.

One other thing, the VHD that is being booted from will expand to the maximum size specified at creation.  It will revert to the used size when you shut it down.  Keep this in mind because that buffer must exist at boot time or else.

[UPDATE for 6/14/2009]  Although this article was originally written using a blank hard drive, I have received a few suggestions for adds, so here they are. 

  1. Backup your machine first.  Yep, this is a good idea as always if you are messing with a drive you care about.
  2. Decrypt the drive if using BitLocker.
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • I foud that if you install Windows 7 AND Server 2008 R2 in VHD and run them on the same Machine: you only have to install the Apps to either a third VHD OR to the fysical disk, that 20 GB is quite enough for the OS and app registrations. ( I am running this since build 7000) like this. If you use this large a vhd, when running from the VHD, it will expand the disk to the above mentioned size and 200GB of diskspace will fill up your disks very fast.

    Please keep that in mind. I am running both on my laptop ( even dualboot the server 2008 R2 With and without Hyper-V.) from a 160 GB harddrive. and I have room to spare.

  • Is it possible to use this to run other OSes ? (besides Win7 and W2k8 r2)

  • I just twittered that question above...if you can do it in Win7, why not in Vista? What changes in the Windows Boot Loader have been made?

    Obviously Vista would have to know about how to interact with the storage controller to find itself once it initializes but after that what would prevent it?


  • Can you backup your current system to a VHD and boot that?

  • As far as I understood the bootloader in this case is the one that comes with W2K8R2, right?

    Is it possible to boot from the VHD file using any other bootloader, like GRUB for example?

    I would suspect so, I believe something along the lines of

    Also, I have heard that you will be able to use the same VHD files on the Hyper-V servers as well. How is the boot organized here?

    Thanks a lot for a very interesting post and screencast. You are bookmarked :)

  • Regarding other boot managers, they would need to understand the .VHD file format which is published.  They would also need to understand the BCD store, how to modify it, etc.  I have no doubt some bright programmer will do something interesting but at the moment this technology is designed for Windows 7 and Windows Server 2008 R2 only.

    As for booting the resulting .VHD using Hyper-V, it doesn't work for me and it doesn't appear SR will recognize how to fix matters so you can.

    The scope of this technology is pretty narrow at the moment and I rather doubt you'll see support for Windows XP and Windows Vista boot scenarios.  

    On the other hand, if you used imagex to create a WIM of your current physical machine, then used that for the imagex apply into the VHD, you might get lucky and have it work with the RC version of WinPE.  I would imagine some of you will be doing a little research over the three day weekend.  Have fun and let me know what you come up with.  

  • How can I have Win7 install on drive V as you did and not rename it to C is it did for you? All my systems have a drive C and I put shared 'greenware' programs with links to C: so that all multi-boot operating systems can have access to these programs without installing and setting up the menu. I've had to create junction points to get my folders to look like they are on C, not a nice way to do it.

    Also, could I take my native install of Win7, back it up and restore to a newly installed .vhd install of win7?

  • Can these .VHD files be "migrated" or "copied" for use/deployment on another machine or in Hyper-V?

  • Hi Keith,

    i have the experience that the vhd doesn´t have the name "windows" inside.


    Kind regards


  • Here is what I have done with this technology:

    Use Windows System Image Manager to create an autounattend.xml file to include partition information, driver folder locations and license key information. Boot to WinPE 3.0 (with scripting installed) and run diskpart script to create partitions including virtual.  Install to virtual disk...

    My experience is that setup always puts the bootloader files in the root of the first partition of the physical disk, even with clean installs from DVD.  The boot loader loads the driver to support the OS in the .vhd file.  Use "bcdedit /enum all" to examine the entries.  Also, the OS installed to a .vhd actually does not appear to use virtualized hardware as in Virtual PC... My installs detect the physical hardware and require the drivers.

    To make your .vhd files portable I think you would have to boot the target machine with PE, create the physical and virtual partitions, create the bcd store with information about booting to the .vhd file, then apply a sysprep'd .wim file to the .vhd.  If your .wim capture process is good and includes all of your out of band drivers and apps then your image should be fairly portable.

    As far as booting older OS's... look to TechNet Magazine about dual booting Vista and XP with the BCD store. Apply an XP image to the .vhd (add Ghost to your WinPE 3.0 disk) and modify the Windows 7 BCD.

  • when i try your steps when i formating drive i got error , i have crypted hdd with bitlocker, but when i disable (decrypt hdd) error are the same, i cant create vhd file,

    help me

  • If I follow this step by step, installing Windows 7 or Windows 2008 R2 to an expandable vhd on a Dell Latitude D830 causes a blue screen after the first reboot following the "Installing updates" section of the install.  If I duplicate the process step by step using a fixed size vhd then the install is successful.  Any suggestions?

  • Sorry Darryl, I don't know why that would fail, and a fixed disk would work.

  • There's a very useful scenario here that I just verified works (on my machine) ... multi-booting Vista as the base install (not in a VHD) with Windows 7 (and presumably WS08R2) in VHD's. I have one machine that I can't convert to Windows 7 until I complete a specific project ... well, I had enough free space on the C: drive that I simply followed Keith's process above to boot the Win7 install disk, create/attach a VHD file on the C: drive and install Win7 to that VHD.

    It modified the boot manager appropriately, and I now can use Vista until I'm done with the project, but I can also use the machine for Win7 ... and the best part is, when I'm ready to cut over, I can just copy off the VHD to my 1.5 TB external USB backup drive, wipe the internal hard drive, install a minimal win7 on the metal (or to a separate VHD), copy the new VHD over, and modify the boot record to point to it again.

    Going forward, I assume I will always install to a VHD because it makes it so easy to restore my machine and switch between profiles. But for right now, it gives me a great hybrid solution with Vista and Win7.

  • From looking at this, I surmise that I can probably transplant the Windows 7 boot loader into Vista, and use that to boot VHD's to test Windows 7 in, also should be able to clone my existing XP to a VHD and boot that too. Gonna have to give this a try later :)