Booting From a VHD (Guide)

Introduction

Have you ever wanted to try a new/beta windows 7/8 operating system but didn't have a spare drive or perhaps you didn't really feel like partitioning your drive? Well, that's the case for a lot of people, luckily there is a fantastic solution that comes in the form of Virtual Hard Drives (VHDs). Now just a disclaimer, this will only work with certain versions of windows, that is : Windows 7 Ultimate or Enterprise, Server 2008 and Windows 8 Pro/Enterprise. The reason for this post is that I only found out about this very recently and I have a feeling not too many people of the general public know about this. For more information about VHD boot, visit this link: http://technet.microsoft.com/en-us/library/dd799282(WS.10).aspx#BKMK_whatIsVHD

Overview

There are very few steps and it's not very complicated, but I'll give a little overview of what will happen. First of all from what I've read if you are using BitLocker you will have a hard time doing this so DO NOT use this guide. The first step will be to create the VHD and the second step will be to mount that drive during the OS installation. So let's get started!

Step 1

Open Control Panel and search for "disk management". Then under Administrative Tools, click "Create and format hard disk partitions"

1_medium

Step 2

In the disk management window you now need to select "Create VHD" from the "Action" menu. Now you need to first name and select a place to save the VHD, so click browse and do so. Then you can either choose VHD or VHDX, it doesn't really matter what you choose here, I chose VHDX just because I felt like it. What you might care about is the disk type, just read the descriptions carefully and choose whichever one best suits your needs. As for size, 60gb is enough to play around with an OS, remember that you need that space in the drive that you're saving the VHD to and also you will have access to your other drives in the OS you install on this VHD.

2_medium

Step 3

Ok so you created your VHD, now if you look in the disk management utility you will see an unallocated disk of it's respective size. Treat this as a physical hard drive.

Now we want to install our OS, well simply go on and boot from the install media. What you want to do here is press SHIFT+F10 at the dialogue where the installer asks you whether you want to upgrade or Custom install. This will open a command prompt. In italic and bold we have what the user writes and in regular font we have what the system writes.

D:\>diskpart

Microsoft DiskPart version 6.2.9200
Copyright (c) 1999-2012 Microsoft Corporation.
On computer: X-PC
DISKPART> select vdisk file=d:\hyper-v\win8_rtm_pro.vhdx
DiskPart successfully selected the virtual disk file.
DISKPART> attach vdisk
	100 percent completed
DiskPart successfully attached the virtual disk file.
DISKPART> exit
Leaving DiskPart...
D:\>

Once you have completed these few steps close the command prompt. From here choose custom install, now you will see your unallocated VHD, create a new partition in it and carry on with your windows installation. Note that in the select vdisk line you must enter YOUR VHD's path, the one there is just my example VHD.

Conclusion

It's really just as simple as that. Now, I have personally only tried this with VHDs on win 8 installing other win 8 builds on VHDs, but it should work equally well with server editions and windows 7. Basically any windows that can mount a VHD during installation. Also your boot menu will then have the new windows and it will be set as the default. You can change this by going in MSConfig:

WINKEY+R then type msconfig.

3_medium

From here you can set whichever one as the default OS and you can also delete any from the boot menu, including the main windows installation so BE CAREFUL.

Final Note/Disclaimer: I have done this a few times, but I am not really a professional. Take your steps with caution and as usual if you are playing with beta software and such, backup your data. If you have any extra tips or corrections, let me know in the comments and I will add them to the post.

Edit:

As jhoff80 states in the comments, the disk creation steps in windows may be skipped by using DiskPart to do the job. So you may simply boot from your media as in STEP 3 but now the steps would be:

D:\>diskpart

Microsoft DiskPart version 6.2.9200
Copyright (c) 1999-2012 Microsoft Corporation.
On computer: X-PC
DISKPART> create vdisk file=d:\hyper-v\win8_rtm_pro.vhdx type=expandable maximum=60000
	100 percent completed
DiskPart successfully created the virtual disk file.
DISKPART> select vdisk file=d:\hyper-v\win8_rtm_pro.vhdx
DiskPart successfully selected the virtual disk file.
DISKPART> attach vdisk
	100 percent completed
DiskPart successfully attached the virtual disk file.
DISKPART> exit
Leaving DiskPart...
D:\>