Windows 7 – VHD Boot – Setup Guideline


Windows 7 has a really useful feature called “VHD Boot”. With that you can boot your entire Windows out of a Virtual Hard Disk file (as those used with Virtual PC or Virtual Server).

This VHD file is mounted as a virtual disk, you can use it as a normal hard disk drive, but all the data is stored in ONE file. The machine is booted physically (unlike with Virtual PC), so you can only run one at a time, but have the full machine’s power.

The advantages are magnificent:

  • Simply copy one file (the .VHD file) and you’re entire system is included.
  • Create incremental VHD files: One VHD file can be based on another one. So if you have different systems, create a base Win7 VHD and make all others incremental. This will save a lot of disk space!

There’re also some small disadvantages 🙂

  • The .VHD booted OS needs to be Windows 7, Windows Server 2008 R2 or later.
  • There’s a performance decrease of about 3%.
  • Hibernate and some BitLocker scenarios don’t work
    (BitLocker CAN be used within the guest VHD though, but not on the disk where the VHD resides).
  • Windows Experience index won’t work.

For the last three months, all my machines have been running as VHD booted ones.

Btw. you can exchange physically booted VHD file with Virtual PC VHD files. All you need to do is running sysprep /generalize /oobe. Also the OS needs to be 32-Bit because of Virtual PC.

So how do you install a VHD-Boot machine?

  1. Boot the system with a setup DVD or USB stick.
  2. At the setup screen, don’t choose “Install Now”, but press “Shift-F10” to get into command line mode [thanks to the many feedbacks for this shortcut!].
    2 
  3. Enter diskpart to start the partitioning utitlity.
    image
  4. Create a new VHD file by entering

    create vdisk file=”D:\pathToVhd.vhd” type=expandable maximum=maxsizeInMegabyte

    For differencing VHDs you need to add an additional parameter parent=”D:\pathtoparent.vhd”.
    image

  5. Now select the new VHD and attach it as a physical disk.

    select vdisk file=”D:\pathToVhd.vhd”
    attach vdisk

    image

  6. After that switch back to the setup window (e.g. using ALT+TAB) and start the setup.
    2
  7. Proceed the normal setup, but make sure you install to the correct disk (normally the last one), ignore the “Windows cannot install to this disk” warning!!

At next startup, you’ll see Windows 7 in the boot menu!

Optional: If you want to add a VHD manually to the boot menu, you just need to copy an existing entry and set some parameters:

bcdedit /copy {originalguid} /d "New Windows 7 Installation"
bcdedit /set {newguid} device vhd=[D:]\Image.vhd
bcdedit /set {newguid} osdevice vhd=[D:]\Image.vhd
bcdedit /set {newguid} detecthal on

 

Btw: My colleague Stefan has posted a detailed article on incremental disks.


Comments (24)

  1. Marco says:

    Hi, i would like to know a thing: can i make a virtual partition copying my actually installation of windows 7 beta 1, so to use it in the future as a backup, or can i only create a virtual partition from 0 ?

  2. KubuS says:

    Let’s see:

    To install a VHD-Boot machine click “Repair your Computer” – hmm… to install I need to click repair, where’s the logic?

    When asked which existing installation should be repaired I need to click into the empty space (select NO installation at all) and press Next? What is this? An Easter Egg or an OS feature?

    I hope it’s just because of the Beta… please, tell me this is not how it’s gonna be done in RTM, please.

    Good feature, but terrible setup experience.

  3. knom says:

    @KubuS:

    =======

    VHD boot is not the normal installation experience. Therefore you need to go into the command prompt and do some preparation. The default way to do this is via the Repair menu..

    So I don’t expect this to change.. 🙂

    But it’s not meant for normal users, but for administrators, who should be able to follow the guide..

  4. Klaus says:

    the normal way to do this is to press Shift-F10. You don’t need to go to repair.

    However, you cannot ignore the warning any more in the RC build, so no way to install to vhd.

  5. VHD - Windows Experience Index says:

    [Window Title]

    Performance Information and Tools

    [Main Instruction]

    The Windows Experience Index for your system could not be computed.

    [Content]

    Could not measure storage performance.

    The disk cannot be accurately assessed while the system is booted from a Virtual Hard Disk.

    [Close]

    [Footer]

    Click here for Windows help

  6. Thomas says:

    Instead of using repair mode simply press SHIFT+F10 on the Install Screen which appears just after Language Selection. The proceed with the diskpart steps.

  7. igorsk says:

    Haven’t checked it myself, but I saw it mentioned that Shift-F10 from the first screen invokes command prompt directly.

  8. WinGuru says:

    Hi,

    a shortcut for Step 2 is Shift+F10 to get the "Command Prompt".

  9. Bydia says:

    How can I keep Win7 from renaming it’s install partition to C and my C to something else?  I need to keep C as C and not create junction points back to it’s contents.

  10. Jack says:

    @Marco,

    You can, but you need to sysprep your machine first, then use Imagex of the Windows AIK to capture your current windows isntallation, then create a vhd file, attach it Just like Keith’s instructions, and Apply the captured WIM file to VHD.  It seems to be the preferred method to install to VHD according to another blog only disavantage is that you need to use bcdedit to add the vhd to the bootselection.

  11. Michael says:

    @Bydia: Every Win Installation names its install partition as C:

    But this has no effect on the other Installations.

    so:

    if you install Vista and Win 7

    – and you start Vista, the Vista partition is C: , 7 f.e. d:

    – and you start 7, the 7 partition is C: , Vista f.e. d:

  12. Jack says:

    Can i Add some other disadvantages of using vhd’s ?

    – Can not use Upgrade function of Windows 7 / 2098 R2

    – Can not use performance indexing

    regards

    Jack

  13. Don says:

    Just press SHIFT-F10 instead of ‘repair your computer’ to access the command prompt.

  14. Daryl says:

    You can open the CLI from the GUI by pressing shift-F10

  15. Razvan says:

    can i use this technique to restore my win7.rc installation ?

  16. khan says:

    install windows 7 on my system

  17. Mike Edwards says:

    You state that one of the requirements is:  The .VHD booted OS needs to be Windows 7, Windows Server 2008 R2 or later.

    Do you know:  will this restriction eventually be relaxed so that I could install Windows Server 2003 SP2 into a VHD file and then boot my workstation from that?   This would useful for those of us who need to support applications that are running (in production) on Server 2003.

    Mike

  18. Robert Jones says:

    Michael said on June 1, that each OS installation takes the drive letter "C" regardless of when/where it’s installed and that’s not true.

    I installed XP, Vista, and W7 and they occupied C, D, and E without me selecting the letters.  Whichever letter was next and not in use (i.e. each unused partition) was used as the OS drive letter.

  19. thommck says:

    Using this guide to get the Windows 8 Dev preview to dual boot with Windows 7 🙂

    Question; If I installed Windows to a VHD on a HyperV R2 server could I then copy that VHD to my local PC and boot to it?

  20. Dan Bugglin says:

    I don't think you need Windows 7?  Windows 8 installer will install the bootloader which is what jneeds to be able to load the VHD yes?  And you create the VHD from inside the Windows 8 installer anyway…

  21. Boot from a VHD is a great feature and Windows XP need it. It could be an excelent mode to load old application. "XP mode" is good but too limited :S

  22. John M. Calvert says:

    Is it possible to boot to VHD using an existing VHD file, e.g. the MS 2010 Information Work Demo? http://www.microsoft.com/…/details.aspx