How to Install Windows 7 to a VHD

Earlier I made a post on how to create and configure a VHD along with explaining exactly what a VHD was. This is a continuation of that article.

Another great feature of Windows 7 is the ability to actually install Windows 7 to a VHD, virtualization without any of the disadvantages of virtualization (full hardware support and so forth). This guide is about how to use the RTM (should work with the RC) DVD to install Windows 7 to a VHD created during installation (or you can use one created during my earlier guide).

I also mentioned the power of this ability earlier, as I listed a possible scenario:

Windows 7’s VHD support will give users the ability to install any operating system that supports booting from a VHD into a VHD. For example, a user could have Vista installed on a single partition, and then have three files (VHDs) anywhere on that disk (or for that matter, on any partition that is readable by Windows) and be able to boot different versions of Windows 7. Assuming that SP1 and SP2 were released (which they are not yet available), a user could hypothetically have four operating systems on a single partition (the number is only limited by the bootloader, four is actually just a random number selected), like so:

  • Vista installed on a primary partition (such as “C:”).
  • Windows 7 RTM installed within a VHD (such as “C:Windows7.vhd”).
  • Windows 7 SP1 installed within another VHD (such as “C:Windows7SP1.vhd”).
  • Windows 7 SP2 installed within yet another VHD (such as “C:Windows7SP2.vhd”).

Of course, the number of VHDs is virtually unlimited, but it’s quite easy to see the hype associated with VHDs in Windows 7.

Now, how would a user get about to actually performing an install of Windows 7 to a VHD?

Take note that this guide will also work with Windows Server 2008 R2.

  1. Boot from the Windows 7 DVD.

  2. Click past the Language Selection screen.

  3. When you’re on the Install Now screen (with the “Install Now” button), stop. Click “SHIFT+F10″ to launch the Command Prompt (don’t bother going through Repair and all that – this is the right way).

  4. First, let’s take a look at the drive letters currently mounted. Type in “fsutil fsinfo drives” and hit enter. This will list all drives (you should know what your drive letters are). Take note of all drive letters.

  5. Now,we need to open “DISKPART.” To do, simply type in “diskpart” and click enter. Pretty easy.

  6. When “DISKPART> ” appears, DISKPART is loaded.

  7. If you want to just use an existing VHD (such as one created in the method I wrote about earlier), then use these two commands (of course C can be swapped out with any drive letter, but either way, you will need to specify the exact path):

    select vdisk file=C:pathtovhdfile.vhd
    attach vdisk

    If you are using an existing VHD, skip to the next step; otherwise, if you would prefer to simply create a new VHD, then use this format of commands (the max option specifies the file size, here I have roughly 6GB, increase as preferred):

    create vdisk file = c:pathtovhdfile.vhd max=6000
    select vdisk file = c:pathtovhdfile.vhd
    attach vdisk
    exit

  8. Now run “fsutil fsinfo drives” again. A new drive letter should have appeared, this is your new VHD. Take note of the drive letter (this isn’t necessary – just making sure everything went OK).

  9. Type “exit” again and hit enter. This will close the Command Prompt.

  10. Click “Install Now” and go through the install as usual, making sure to select the “Custom” option when it appears.

  11. When you come to the list of partitions and you are asked to choose an install location, ignore any warnings and select the partition that matches the size that you used for your VHD.

  12. Windows 7 will automatically configure your boot loader for the VHD, but this is easily fixed. Just continue as normal, and when the installation completes and it prepares to reboot, it will show you the bootloader (should have two “Windows 7″ options if you already had a Windows 7 install, this is normal). Select either OS and continue (just make sure that it’s a Windows 7).

  13. Now, if you are fine with the way the bootloader appears, you can quit now. Otherwise, you can follow this guide and use the bcdedit command-line tool (really easy, only three commands) or download EasyBCD and use that to do this yourself. However, I suggest using bcdedit and making your bootloader a little more clear (Again, you can opt for EasyBCD if you prefer a graphical menu). open the Command Prompt as an Administrator (right click and select “Run As Administrator”).

  14. Type in “bcdedit /v” and hit enter. This will display a list of entries in the Windows 7 bootloader.

  15. Determine the VHD install and copy the GUID (listed as identifier) and create a new command like the following (replacing GUID with your identifer (should be a really long set of numbers with hyphens – include all of it)):

    Take note that you can edit the description as you wish. This is what will appear in the bootloader.

    bcdedit /set {GUID} description “Windows 7 (VHD)”

  16. If you want your VHD install to appear last (or second) in the bootloader, then execute this (again, replacing GUID):

    bcdedit /displayorder {GUID} /addlast

Now, enjoy your new Windows 7 install. :) Feel free to leave a comment or ask questions in the comments.

Subscribe & Connect

Share This Post: 

Subscribe to our e-mail newsletter for updates:

, , , , ,

13 Responses to How to Install Windows 7 to a VHD

  1. Anonymous August 27, 2009 at 2:17 am #

    great enlightening trilogy tutorial, thank you for making me aware of this feature in windows 7.
    this would be great for carrying round a copy of an OS on an external hard drive or better yet a flash drive and load up my own personal, portable OS anywhere with windows 7 is present

    once again thank you

  2. MSTF August 27, 2009 at 8:10 am #

    can we install xp to vhd? if we can, how??

    Thank you this article

    • Robert Bernard August 28, 2009 at 8:53 am #

      XP does not supporting booting from a VHD, so at this time, it is not yet possible.

  3. MiniMe August 27, 2009 at 10:39 am #

    Just installed Windows 7 (RC) to a dynamically expanded VHD on a Vista based computer. Everything works fine, just the Windows 7 boot process takes long (probably because of the VHD).

    One should note, however, that the Windows 7 install process replaces any custom Vista bootloader that one may have. In this case, one should seek alternative ways to restore Vista functionality the custom bootloader was providing.

  4. RoadRacer August 27, 2009 at 12:24 pm #

    Thanks for this very very helpfull site and article…
    But how to install Windows XP? Because i cant hit the key shift + F10 during xp installation

    Regards

  5. MiniMe August 27, 2009 at 1:32 pm #

    I don’t think any other system that Windows 7 can be installed in a VHD this way. Simply because only W7 natively supports VHDs. For the rest of them, you may have to resort to your favourite virtualization solution; or just XP mode inside Windows 7.

  6. Robert Morgan August 31, 2009 at 12:43 pm #

    Thanks for this very very helpful article also…

  7. Anonymous September 19, 2009 at 4:21 pm #

    can i place the vhd into pendrive and boot on other computers?

  8. Anonymous September 23, 2009 at 9:07 am #

    I installed windows 7 VHD from virtual pc 2007. When i loaded windows 7 in Virtual pc, i ran the sysprep command :C:windowssystem32sysprepsysprep /generalize /shutdown and then linked the vhd to the boot menu.

    It worked like a charm.

  9. hoym888 October 10, 2009 at 9:20 pm #

    Robert

    Your article is great.
    i have created a VHD as instructed to run WinXP so that i can swap between it and my host Win7 system. However, i don’t know howto transfer data ( sharing files ) between ” host ” and ” guess “.

    Can you ( or any other mentor ) please teach me ?

    hoym888@gmail.com

  10. Jules January 20, 2010 at 5:50 am #

    which version of windows 7 can i install to file?
    only ultimate and enterprise?
    or can i do it with professional as well?

  11. Guest January 17, 2012 at 7:00 am #

    you can install XP into a VHD using v-boot (ca. 70$ for one PC)

Leave a Reply