Creating and Booting From a VHD File

Abel Chajet
Tech Jobs Academy
Published in
5 min readJan 27, 2016
In place of multiple Charlie Chaplins, imagine versions of Windows (from “The Circus”, 1928)

Booting into two different operating systems on one machine can be accomplished without dividing up a hard drive into multiple partitions. In this tutorial, I will walk through the steps of setting a Virtual Hard Disk file, or VHD, into native boot mode. Since VHD’s were originally created to be used as files on which virtual machines boot operating systems, their malleability is ideal for those who want to experiment with Windows and learn more about different versions. Booting from a VHD file also allows for performance substantially greater than simply running the VHD in a virtual machine inside another operating system. Once you know how to create a VHD, you can boot many different types of Windows from your PC’s BIOS or within a virtual machine. In six steps, you can begin turning your PC into a hall of mirrors that lets you see the many different variations of Windows from all angles.

Please note that this post is for those who already have some experience with Windows operating systems. Beware that tinkering with how your system boots could leave your BIOS without a means to access a working partition; I recommend making a USB recovery drive (instructions here) to make sure you can restore your OS if anything goes wrong. You will also need a version of Windows to install on the VHD, so keep on hand an .ISO or other installation media containing your Windows version of choice. Some level of familiarity with the Windows command line is also required, and though most of the process can be completed graphically, if you are not comfortable with typing in commands that can modify your system on a very basic level, you can learn more about the Windows command line interface here.

Let’s begin:

  1. Open a program called “Disk Manager” by hitting Windows + R, typing in “diskmgmt.msc”, and pressing Enter.
  2. Disk Management should look like this on Windows 10, if you only have one partition:
A simple, basic, healthy disk

Select your main drive, usually labeled “C:”. Under the “Action” menu, hit “Create VHD”. You will be asked where to create the file (I recommend a simple and straightforward path, preferably in a new folder), whether a VHD or VHDX file should be made (for simplicity and maximum compatibility, choose VHD), and to choose between fixed size and dynamically expanding (go with fixed size). The parameters are pictured here:

When deciding how much disk space to allocate for the VHD, keep in mind the minimum system requirements for the operating system you would like to use. Windows 10 needs at least 20 GB for a 64-bit system; Server 2012 needs a bare minimum of 32 GB.

3. After the VHD file has been created, select “Attach VHD” from the action menu. You will need to format the drive; right click on the non-allocated partition in the newly created drive and select “Initialize Disk”, as seen here:

This will enable you to create partitions on the VHD, in the same way you would on a physical drive. Select the MBR, or Master Boot Record, option to ensure maximum compatibility.

MBR is backwards compatible, GPT is not

4. Now right click on the unallocated disk space and select “New Simple Volume” to open a graphical wizard which will walk you through the necessary steps to create an NTFS partition for the drive.

5. These next steps will require the use of the command line. To apply a bootable Windows image to the VHD, get that .ISO or other installation media I mentioned earlier, as well as a suite of tools from Microsoft called the Windows Automated Installation Kit (AIK) found here. Install the AIK, then open the Deployment Tools Command Prompt, pictured here

and type the following:

imagex /info [path containing the installation .wim file on the Windows install .ISO]

That command will return a lot of information about what versions are contained on that .ISO, and what the image index number for each version is. You might want to install Windows 7 with a different configuration alongside an existing install to get a different perspective on the OS. Alternatively, you could install a version of Windows Server 2012 R2 and run it in Server Core mode for a comically thin reflection of the full GUI version.

6. After you’ve found the index number of the version you want to install, enter this command:

imagex /apply [path of .wim file] [desired image index number] [virtual disk]

For example: imagex /apply E:\SOURCES\INSTALL.WIM 9 V:\

Applying an image to the VHD can take some time, so take a break and grab a snack to reward yourself for getting this far.

7. Once the image has been applied, open up a new command line shell as Administrator and type in “bcdboot [VHD drive letter]:\windows”. This designates the VHD partition as a bootable drive by copying critical files required to boot. Restart and enter the BIOS options on your machine — methods vary across PC makes and models — to enter a boot menu that will let you choose between your current partition and the VHD. Choose the VHD drive and congratulations! You now have a fully functional, bootable drive running a Windows version of your choice on the same partition as your main drive!

Now that you can make a VHD file, you can fill your hard drive with different versions of Windows Server and operating systems to experiment and enhance your skills. Install Windows 2012 R2 Server Core on a VHD to gain familiarity with a command line-only interface, or Windows 10 to test out legacy programs on Microsoft’s latest OS. You can make more VHD’s to use inside those bootable VHD’s and run them in virtual machines. The only limitation to creating the Windows equivalent of an endless hall of fun-house mirrors is the amount of storage and RAM available on your PC.

Many thanks goes to my instructor Thomas Titanski for his dedication and patience, and all the students and staff at Tech Jobs Academy for their support. Sources include https://technet.microsoft.com/en-us/library/dd799299(v=ws.10).aspx and https://technet.microsoft.com/en-us/library/dd744338(WS.10).aspx

--

--