Booting from a VHD disk

Windows 7 and Windows 2008 R2 have 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.

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.
    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

  • Now select the new VHD and attach it as a physical disk.select vdisk file=”D:\pathToVhd.vhd”
    attach vdisk

    image
  • After that switch back to the setup window (e.g. using ALT+TAB) and start the setup.
    2
  • 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

    Source : Microsoft.

    For more information.
    Microsoft Technet : Understanding virtual harddisks with native boot.
    Microsoft Technet : Deploy a virtual hard disk for native boot
    Microsoft Technet : Add a native boot virtual hard disk to the boot menu
    Microsoft Virtualization Blog : Native VHD Support in Windows 7

    Related articles:

    Disclaimer.
    The information in this article is provided “AS IS” with no warranties, and confers no rights. This article does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.

    Marco

    Marco works for ViaData as a Senior Technical Consultant. He has over 15 years experience as a system engineer and consultant, specialized in virtualization. VMware VCP4, VCP5-DC & VCP5-DT. VMware vExpert 2013, 2014,2015 & 2016. Microsoft MCSE & MCITP Enterprise Administrator. Veeam VMSP, VMTSP & VMCE.