Поделиться через


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

  • Anonymous
    April 06, 2009
    PingBack from http://asp-net-hosting.simplynetdev.com/windows-7-%e2%80%93-vhd-boot-%e2%80%93-setup-guideline/

  • Anonymous
    April 06, 2009
    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 ?

  • Anonymous
    April 06, 2009
    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.

  • Anonymous
    April 06, 2009
    @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..

  • Anonymous
    May 05, 2009
    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.

  • Anonymous
    May 06, 2009
    [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

  • Anonymous
    May 08, 2009
    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.

  • Anonymous
    May 08, 2009
    Haven't checked it myself, but I saw it mentioned that Shift-F10 from the first screen invokes command prompt directly.

  • Anonymous
    May 12, 2009
    Hi, a shortcut for Step 2 is Shift+F10 to get the "Command Prompt".

  • Anonymous
    May 21, 2009
    You can also boot from VHD with Vista SP1 if you replace its bootloader. http://blogs.technet.com/aviraj/archive/2009/01/28/windows-7-boot-from-vhd-first-impression-part-3-booting-vhd-from-vista-sp1-or-later.aspx

  • Anonymous
    May 22, 2009
    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.

  • Anonymous
    May 30, 2009
    @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.

  • Anonymous
    June 01, 2009
    @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:
  • Anonymous
    June 01, 2009
    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
  • Anonymous
    June 26, 2009
    Just press SHIFT-F10 instead of 'repair your computer' to access the command prompt.

  • Anonymous
    August 01, 2009
    You can open the CLI from the GUI by pressing shift-F10

  • Anonymous
    August 06, 2009
    can i use this technique to restore my win7.rc installation ?

  • Anonymous
    November 28, 2009
    install windows 7 on my system

  • Anonymous
    November 29, 2009
    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

  • Anonymous
    November 30, 2009
    The comment has been removed

  • Anonymous
    September 13, 2011
    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?

  • Anonymous
    September 15, 2011
    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...

  • Anonymous
    September 16, 2011
    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

  • Anonymous
    September 23, 2011
    Is it possible to boot to VHD using an existing VHD file, e.g. the MS 2010 Information Work Demo? www.microsoft.com/.../details.aspx