Hard Drive with Monster Face

The Care and Feeding of Bootable VHDs

[st_row][st_column][st_text id_wrapper=”text_416ed301421ce60eb63b6568c496cbbe” ]Like many ITCertPros that have been studying Microsoft technology, I have worked with virtual machines for studying the technology as well as supporting production servers. I have used Virtual PC, Virtual Server, and Hyper-V to create virtual environments to learn about software before I take a certification test. Having a computer that could boot multiple operating systems was one option, but it was usually difficult to setup. Each OS had to have its own partition, which meant trying to re-partition your current hard drive or buying a new hard drive. Beginning with Windows 7, we gained another option: Boot to VHD (Virtual Hard Disk). This allows us to create an OS installation inside a Microsoft VHD file and boot the computer from the OS in the VHD. Typically, VHDs are used as the hard drive for Microsoft virtual machines, such as Hyper-V and Virtual PC. I have been working with bootable VHDs for about three years now. They can be very useful for trying out different operating systems. My original reason for installing a bootable VHD was to use Windows Server 2008R2 and Hyper-V. Windows 7 and Virtual PC do not support 64 bit operating systems, so it is impossible to work with virtual Windows Server machines. I wanted to use Microsoft virtualization for my virtual machines, so I knew that I had to use Hyper-V and Server 2008. By using a bootable VHD with Windows Server 2008, I spared myself the trouble of having to re-partition my hard drive. Another reason for using bootable VHDs is to participate in BYOD HOLs* (Bring Your Own Device Hands On Labs, my new acronym combination. J) TechMentor Las Vegas is offering Deep Dive Sessions and Hands on Labs that require participants to bring their own computers for the labs. So unless you have spare laptops you can reformat or can remotely connect to a server, a bootable VHD might be your best solution. The solution I am presenting is not my own, and is mostly based on a blog post by Harold Wong of Microsoft. The best feature of Mr. Wong’s procedure is that it mostly uses GUI tools instead of the command prompt. However, the article left me with some questions. After doing some research on some more blogs and websites, I have answers to my questions and I thought that it would be helpful to have all this information in one place. I have placed references below to all the websites that I have used to create this article. Also, while Mr. Wong’s article gave detailed instructions for creating the VHD in Windows 7, I am going to focus my instructions on creating the VHD in Windows 8. The techniques used in these instructions can be used to create VHDs of Windows 7, Windows Server 2008 R2, Windows 8, Windows Server 2012, Windows 8.1, and Windows Server 2012 R2.


  1. The main OS on your laptop needs to be at least Windows 7 or Windows Server 2008 R2.
  2. Installation files for the OS you will be installing to the VHD. You can use Evaluation versions or licensed versions. This might be a DVD or USB drive. It could also be an .ISO file. Windows 8 and Windows Server 2012 are able to natively mount ISO files However, Windows 7 and Windows Server 2008 R2 will need a program like Magic ISO to mount the files.
  3. A copy of imagex.exe from the Windows Automated Installation Kit (WAIK).

Creating the VHD

  1. Open the Computer Management Console. (Press Windows X and choose Computer Management or Press Windows R and type compmgmt.msc)
  2. Click on Disk Management.
  3. Right Click on Disk Management and select Create VHD
  4. In the Create and Attach Virtual hard Disk dialog box:
    1. In the Location, enter a path and filename for the VHD. Consider using a dedicated folder to store your VHDs.
    2. Enter a size for the virtual hard disk. Mr. Wong recommends 20 GB. If you are considering installing applications, especially Office 2013, consider 30 – 35 GB.
    3. Choose a virtual hard disk format. Dynamically expanding will work well.
  5. Right Click on the newly created virtual disk and select Initialize Disk. Right click in the volume area and format the disk as a simple volume.
  6. (Optional) If you possibly may want to use this disk later with Hyper-V, Right Click on the volume and select Mark Partition as Active.
  7. Open a command prompt running as Administrator.
  8. Type the following command: imagex /apply e:sourcesinstall.wim 1 f: where e: is the drive letter of the OS source files f: is the drive letter of the virtual disk 1 is the index number for the image and is the correct value for a client OS.
  9. (Optional) If you are installing a Windows Server OS to the VHD, it is helpful to identify an index number for an image containing the GUI tools instead of the Server Core.
    1. Open a Windows PowerShell prompt running as Administrator and type: Get-WindowsImage -ImagePath e:sourcesinstall.wim
    2. Look for an image labeled SERVERDATACENTER (not SERVERDATACENTERCORE). This is the index number you will want to use instead.
  10. (Optional) Make a backup copy of the VHD.
    1. From the Computer Management Console, Click on Disk Management.
    2. Right Click on the VHD drive and select Detach VHD.
    3. Open Windows Explorer and browse to the folder containing the VHD.
    4. Copy the VHD to another folder or USB drive.
    5. Back in the Computer Management Console, Right Click on Disk Management and select Attach VHD
    6. In the Attach Virtual Hard Disk dialog box, Browse to the VHD file and click on the Open button
    7. Click OK
  11. Go back to the previously opened command prompt or open another command prompt running as Administrator.
  12. Type the following command: bcdboot f:windows where f: is the drive letter given to the currently mounted VHD.
  13. The first time you boot to this partition, Windows will detect drivers and prompt you with the tasks you would normally run on a new installation.
  14. One more note, when you reboot windows, the currently mounted VHDs will be dismounted the next time you reboot. This is normal.
  15. If you want an even easier method, Hugo Häggmark has created a script to do most of the work. But where is the fun in that? J

Remove the VHD from the Boot Menu

If you are done with the VHD and no longer want to boot to it, you can remove it from the boot menu using these steps.

  1. Open MSCONFIG. Press Windows R on the keyboard, type msconfig, and press enter.
  2. Click on the Boot tab
  3. Highlight the entry for the VHD
  4. Click on the Delete Button

Expand the VHD

This method will work for a detached and unencrypted VHD. I recommend running this from your computer’s main OS.

  1. Make a Backup copy of your VHD.
  2. Open a command prompt running as Administrator.
  3. Type DiskPart and hit enter.
  4. Type select vdisk file=f:vhdmydisk.vhd where f:vhdmydisk.vhd is the path and filename to the VHD you want to expand.
  5. Type expand vdisk maximum=30000 where 30000 is the new size in Mb. 30,000 would be close to 30 Gb.
  6. Open the Computer Management Console.
  7. Click on Disk Management.
  8. Right Click on Disk Management and select Attach VHD
  9. In the Attach Virtual Hard Disk dialog box, Browse to the VHD file and click on the Open button
  10. Click OK
  11. Right click on the volume you want to extend and select Extend Volume.
  12. (Optional) If the VHD is encrypted with BitLocker, it will detect that the drive has been tampered with.
    1. When booting, you must enter the recovery key and boot into Safe Mode.
    2. Go to BitLocker Drive Encryption manager and hit Manage BitLocker.
    3. Change the PIN and save the new recovery key.

Add the VHD to Hyper-V

  1. Open the Computer Management Console.
  2. Click on Disk Management.
  3. Right Click on Disk Management and select Attach VHD
  4. In the Attach Virtual Hard Disk dialog box, Browse to the VHD file and click on the Open button
  5. Click OK
  6. Right Click on the volume and select Mark Partition as Active.
  7. Open the Hyper-V Manager
  8. From the Actions pane, click on New, Virtual Machine.
  9. Click Next
  10. Name the Virtual Machine
  11. Check the box to Store the virtual machine in a different location.
  12. Browse to the folder of the VHD. Click Next.
  13. Enter value for Startup memory and decide whether to use Dynamic Memory. Click Next.
  14. Configure Networking and Click Next.
  15. Select Use an existing virtual hard disk. Browse to the location of the VHD. Click Next.
  16. Click Finish. You can now use your VHD with Hyper-V.


Harold Wong, How to Create Windows 8 VHD for Boot to VHD using simple, easy to follow steps, http://blogs.technet.com/b/haroldwong/archive/2012/08/18/how-to-create-windows-8-vhd-for-boot-to-vhd-using-simple-easy-to-follow-steps.aspx Keith Combs, Dual Boot from VHD Using Windows 7 and Windows Server 2008 R2, http://blogs.technet.com/b/keithcombs/archive/2009/05/22/dual-boot-from-vhd-using-windows-7-and-windows-server-2008-r2.aspx Hugo Häggmark, Creating a bootable VHD the easy way, http://www.hugohaggmark.com/2010/09/23/creating-a-bootable-vhd-the-easy-way/ TechNet, Windows Server Installation Options, http://technet.microsoft.com/library/hh831786 Nicklas Håkansson, Expanding VHD, http://blogs.msdn.com/b/nicklash/archive/2010/10/12/expanding-vhd.aspx Daniel Petri, How to Extend a Disk Partition in Windows Vista and Server 2008, http://www.petri.co.il/extend-disk-partition-vista-windows-server-2008.htm[/st_text][/st_column][/st_row]





Discover more from ITCertPro

Subscribe now to keep reading and get access to the full archive.

Continue reading