How To: Boot your PC from a VHD

With the release of Windows 7, Microsoft added the ability to boot off of VHD files using the new BCD boot manager. The major advantage of this is that it allows you to create the virtual disk on an existing partition and boot directly off that file rather than having to create a new partition on your physical hard disk/SSD.

Another bonus is that you can provision a dynamically expanding VHD so you only take up the space you need. For example, if you create a 120 GB dynamically allocated VHD and install Windows on it you will only consume around 8 – 10 GB (depending on OS) of space on the partition where the VHD is held. The VHD file will grow as additional room is needed, but the flexibility of not having to carve out a dedicated partition can be a big bonus. One drawback to keep in mind is the slight performance impact on the OS you are installing on the VHD, but in my instance this was not a problem.

I finally had a chance to give this feature a try when I decided to dual-boot my Windows 7 PC with Windows Server 2008 R2 running Hyper-V. A quick Google search turned up the this blog post.

Using the instructions in this post, I was able to successfully install and boot Windows Server 2008 R2 along with the Hyper-V role while minimizing disk space usage. The following steps are a condensed form of the instructions from Scott’s blog post:

NOTE: These instructions will only work if you already have an existing Windows Vista or 7 installation. See Scott’s blog for additional information if this does not fit your scenario.

  1. Boot off of your Windows 7/2008 R2 disk.

  2. Proceed with the installation as normal until you get to the screen with the “Install Now” Button. Click the “Repair your computer” link at the bottom of the install window.

  3. De-select any Windows installations that are found (just click the white area below that entry) and click Next.

  4. Select “Command Prompt”.

  5. Type “diskpart” (without quotes) and press Enter.

  6. Enter in the following command, replacing the “file=” and “maximum=” parameters as needed. Maximum specifies the largest size the VHD can grow. Make sure you specify a directory that exists after “file=”. This command will not create the directory along with the VHD file for you, it will only create the VHD. create vdisk file=“C:\win7.vhd” type=expandable maximum=50000

  7. Now that the VHD has been created, enter the following commands to mount it. Make sure you specify the same VHD and location that you entered in the previous step. select vdisk file=“c:\win7\win7.vhd” attach vdisk

  8.  Now type exit to quit disk part, close the command prompt, close the system repair window (click the “x” button, not reboot or shutdown), and proceed with the normal Windows installation. If everything went as expected you should see the VHD in the installation destination list. Choose that as you installation location and the rest is exactly the same as a normal Windows install.

 

comments powered by Disqus