Booting to VHD: Think like a novice, look like a virtual pro

@Carl Boisson
Tech Jobs Academy
Published in
10 min readJan 27, 2016
You’re a few steps from magic!

Microsoft has a way for you to play with new (or old) operating systems and tools right from your home PC without disturbing your current configuration. It’s as simple as loading a VHD file and telling your computer to boot into it!

A VHD (Virtual Hard Disk) is a special type of file which contains the virtual (or simulated) contents of an HDD (hard disk drive). This can be one folder containing one file, or an entire partition, with its own sub-folders and files. Let’s imagine your “C: drive” (commonly the drive letter designated to the HDD which physically contains all of your folders, files and programs) is a mansion with many rooms that have become furnished over time (usually by you and your Operating System). Within this example, your music folder would be a “room” with your songs, the “furniture.” Loading a VHD would be like magically accessing a fully-furnished room or space within your home (your computer). When you open the magic key, you’re walking into a pre-designed space with its own wallpaper, sofa-bed, washing machine and chandelier. A VHD may contain its own operating system, folder structure, files and settings which are separate from those of the host (real) computer. The idea is, when you’ve finished exploring this space, you can shut the door, return home and everything remains as you left it. The best part is, you can visit this magical space whenever you want!*

In the IT world, VHDs are used for accessing and running virtual machines for a variety of reasons. They are more cost effective than purchasing additional physical hardware, such as PCs and Servers. They’re a great way to take advantage of the tremendous processing power of modern CPUs. IT or computer science students may also use VHDs to practice their budding skills. They can load virtual machines on their PCs without worrying about tampering with any critical files on their real machine. Consumers may find that VHDs are useful for previewing new operating systems (OS) before purchasing. For example if you’re curious about Windows 10, you can find a VHD of Microsoft’s latest OS and test it out before you commit to upgrading.

If you’ve never done this before, the process can seem daunting. Don’t worry, it’s pretty straight-forward. There are a few things you’ll have to consider. First, you’ll want to find a step-by-step guide to walk you through the process. Since you’re already midway into reading this post, I’m going to recommend using this one! (I may be a bit biased). Then you’ll have to find an appropriate VHD that you want to use. For this example, we’re going to use Windows Server 2012 R2.

It is absolutely crucial that you make sure the system you’re running (the computer you intend to download/run the VHD on) meets two criteria. Your PC Must:

1) Have the amount of physical HDD space required to both save and “unpack” the VHD. The source of your VHD will usually have the file size listed. For example, if the VHD file you found is 2GB, and it unpacks to 2GB, you will need roughly 4GB of available space. In this case the VHD file itself will be stored on your HDD using 2GB and the virtual drive, (magic mansion room), will “manifest” itself as another 2GB. Right-click on any drive and select properties to display remaining free space.

The pie chart makes it easy to tell how much free space is remaining.

2) Meet the minimum requirements of the software/operating system that will be running on the VHD. For example, if you’re using a Windows 7 PC, your computer already meets the minimum requirements needed for Windows 7. However, if you intend to run a VHD with Windows Server 2012 R2 on it, you’ll need to ensure your PC meets the minimum requirements for Windows Server 2012 R2 and Windows 7. The system requirements are usually documented alongside the source of the VHD files you would be using, or you can search the vendor’s website for it (ie. you would check Microsoft’s website for the system requirements of Windows Server). If you “right-click” My Computer and choose properties, it will display an overview of your computer’s configuration which, you can compare to the system requirements of your VHD.

Some VHDs require your Operating System be 64-bit

You can find the VHD I used for this example here (you may have to register). Once you’ve downloaded your VHD, you’ll want to put it in an easy place to find. If you download it off the internet, by default the VHD would will be saved to your Downloads folder. If you’re unsure where the file ended up, don’t worry, you can always search for it by name, or extension. For example, if you search your C: drive using *.VHD you would see the results for all files that end in .VHD that are on that HDD.

Take note of where your VHD file is saved to.
Windows has powerful search tools built in just in case you’ve misplaced your VHD.
The VHD I used originally had 80 characters. Changing the name prevented MANY typos.

Because you will have to reference the exact location of the VHD in later steps, it’s easiest to place the file directly into your C: drive and not within other folders and sub-folders. This will save you from having to type out a lot of “/”s and folder names down the line. For this same reason, you’ll also want to change the name of the file by right-clicking and selecting Rename. You can rename the file to something shorter that will be easier to type. Take note of where your VHD file is saved to.

Note: Avoid changing the extension, that is, make sure .VHD remains part of the name. Otherwise, Windows will not know that this is a VHD. For this example, I changed the name to “Server2012.vhd”.

The best way to copy the VHD to your desired destination is using Command Prompt. We will be using it quite a bit in this guide. The Command Prompt is a small program that allows a user to perform a multitude of computer operations using preset commands. These special tools and instructions use letters, symbols and numbers instead of using a mouse to “point-and-click” menu items within a GUI (graphical user interface). Although we will use a few programs for the next few steps, they will all be accessible within the same Command Prompt interface.

To find Command Prompt on any Windows 7 (or later) computer, simply click the Start button on your desktop to search and type Command Prompt. (On Windows 8.1 or later, you can quickly access the Command Prompt by right-clicking the “Windows button” on the bottom left of your desktop). Note: If you share a computer and there are multiple user accounts, you may have to right-click the Command Prompt shortcut and choose “Run As Administrator” to continue past this step. If your account isn’t the Administrator (usually the main user with the security clearance to make major changes), that person may have to enter their name and password to allow you to proceed.

“Search” is an easy way to find programs and files

In this example, we’re going to copy our VHD file from the “downloads” folder to the “C: drive”. Once we’ve started Command Prompt, we will type in the following command so that the file is moved to our preferred location:

copy [source] [destination]

So if your file is on the “J: drive” you would type “J:” in the [source] and if you wanted to copy to drive “C:”, you would type the corresponding drive letter instead of [destination]. Hit the Enter key on your keyboard to instruct Command Prompt to carry out the instructions you just gave it. If you are successful you should see a message like this:

This is why we needed to take note of where we saved our VHD.

Now that you’ve moved the VHD to a new location, you’ll have to enter a few more commands to unpack the VHD. Afterwards, you’ll need to tell your computer to look for a specific file within the unpacked VHD. Remember our mansion example? Somewhere in this “virtual home” is a copy of its “key”. In order to get that key, you’ll have to tell your computer to get it from a specific box within a specific room. Afterwards, you’ll be able to go directly into the virtual space whenever you want!

In order to attach the VHD to your computer you will use a tool called DiskPart to creation a new partition (section) on your HDD. This will unpack the files embedded in the VHD so that you can access them to extract that “key”. DiskPart is accessible within Command Prompt by typing diskpart and hitting the Enter key on your keyboard.

Once you have completed that step you now want to tell DiskPart where to get the file (VHD) to create the partition with:

select vdisk file=[location of your VHD]
attach vdisk

The VHD that you just loaded with DiskPart was automatically assigned a drive letter (such as “J:” or “I:”).

Notice your VHD was loaded with a unique drive letter containing its own folders and program files.

We now want to tell our PC what letter we would like to assign that drive. DiskPart will allow you to see a list of the drives on your PC according to their volume number (a numerical value attached to each drive). Once you have verified which number the new drive was assigned, you can now instruct your computer to change it to whatever you’d like. Bear in mind, you’ll want to remember the drive letter you chose for the next step. Enter that number below (without the “[” or “]”).

list volume
select volume [volume_number_of_attached_VHD]
assign letter=v
exit

Notice that when you typed exit and pressed Enter on your keyboard in the last step, the Command Prompt remained open. This is a useful way to navigate to the different tools within this program without unnecessary clicking and mouse gestures. We will now use the BCDboot tool (still accessible within Command Prompt) to point our computer to that “key” to the magic mansion.

cd v:\windows\system32
bcdboot v:\windows

Your “key” has been found and saved! At this point, you’ve told your computer you want the option to enter this “magical space” whenever you turn on your PC. Your PC now knows where to find the VHD and how to access it. You no longer need the VHD to remain unpacked, so the next step is just cleaning up. While still in Command Prompt, we want to tell DiskPart to unload the VHD since it has already retrieved the “key”.

diskpart
select vdisk file=C:\server2012.vhd
detach vdisk
exit

Congratulations! The next time you restart you computer, your boot manager (a screen that shows up before Windows loads) will present you the option of starting your computer using the VHD. It will usually have the name of the Operating System that is embedded within it. For example, if you’re running Windows 7 and your VHD contained Windows Server 2012, you’ll see an option to choose one of the two. Simply choose your new option to load into your “magic mansion”!

Boot options on startup.
What you’ll see once you’ve successfully booted into your VHD.
Notice your VHD has its own “C: drive” that is separate from yours.

Cleaning up:

After you’ve toyed and tinkered for hours, days, weeks or months within your magical space, you may decide you no longer have a need for the additional boot-up option.

*Also, some Software or Operating Systems contained in your VHD may have specific licensing terms, in other words, they may expire. While your computer will allow you to access your “magic mansion”, the doors would be locked due to the vendor’s restrictions. Pay close attention, the cleanup is very straight-forward, but if done improperly can cause major frustration and may prevent normal boot-up into your real Operating System. This step must be performed in your real Operating System, and not from within the VHD. To be clear, if your PC is running Windows 7 and you set up a VHD which contains Windows Server 2012, you must perform this step within Windows 7 (your real operating system).

In Windows 7 (or later), click the “Start” button on your desktop. In the Search pane, type in msconfig. MSConfig (system configuration) is another small tool which allows you to configure a few basic parameters of your Operating System, including how it boots up and which programs start alongside Windows.

Once again, search comes in handy.

Select the Boot tab, then select the boot option you would like to delete. Note: Your real Operating System should say “Current OS” next to it. You DO NOT want to delete that one!

Read carefully.

At this point your PC is back to normal and it should boot directly into your Operating System (ie. Windows 7). You may have been a novice when you started reading this, but you have now downloaded a Virtual Hard Disk, told Windows where you want it to live, and used the Command Prompt to tell Windows to give you access to your “magic mansion”! If you’re interested, there are more resources available to learn how to edit existing VHDs to your liking or even make some on your own!

Resources:|TechNet VHD guide| Additional VHD guide|VHDs for backups

Key Terms:
BCDboot
Command Prompt
CPU
DiskPart
File Extension
Files
Folders
Hardware
HDD
MSConfig
Operating System
PC
VHD
Configuration
Boot
Load
Virtual Machine
Partition
Server
Software
System Requirements
Windows 7/8.1/10/Server2012

--

--