In this guide, I will explain how to install Windows 8 on a VHD (Virtual Hard Disk). This methods lets you have a second (or many more) bootable operating systems without having to dedicate a complete partition for every OS installed (and without affecting your current Windows installation!). A VHD is essentially a complete partition contained within a single file on the disk. Don’t want that OS anymore? Simply delete the .VHD file and you’re done. Quick and simple.

Now where VHD becomes handy is in testing the new developer preview builds of Windows 8. Note that this method will work on future builds of Windows 8 (Beta, RC and final) as well as Windows 7 and Windows Server 2008 R2. For the purposes of this guide, I’ll assume you currently have Windows 7 installed natively on your machine and want to install the Windows 8 Developer Preview on a VHD. Before we start, you should have already burned the installation ISO of Windows 8 to a DVD or made a bootable USB installation media.

A) Create a new empty VHD

A.1) Launch the Computer Management console (found in Control Panel > Administrative Tools).
A.2) Right-click on Disk Management (under Storage) and choose Create VHD. (Note: You might need to click on Disk Management first, then wait for it to load before you can have the contextual menu with the Create VHD option.)
A.3) Enter the location of the .VHD file. I HIGHLY recommend to place this file on the root of any disk. Note that you will need to remember the path of this file for use later in this guide.
A.4) Enter the disk space (80GB is usually good for most uses) and choose the Fixed size format.
A.5) Click OK and wait for the VHD creation to complete (displayed in the window footer). It usually takes about 5-15 minutes to complete.

B) Install Windows 8 on the VHD

B.1) Reboot the computer with the installation disk (or USB drive) inserted and boot from it.
B.2) On the first installation screen, choose the language options, then click Install Now.
B.3) Accept the license agreement and then choose Custom Installation.
B.4) On this screen, a list of available partitions/disks are displayed. But it’s missing the VHD we created earlier. This is because we need to attach it first.
B.5) Press SHIFT + F10, a command prompt window will appear.
B.6) Type the following command: diskpart
B.7) Then type the command (replace win8.vhd with the name of your VHD): select vdisk file=C:\win8.vhd
—> Got an error? This is because the drive letters may not be assigned in the same order as in Windows. Fortunately, the setup lists them starting from letter C and going up. So try the command again but this time using D:\win8.vhd, then E:\win8.vhd, etc. until it works.
B.8) Once you get a successful message, type the command: attach vdisk
B.9) Once your VHD is attached, type exit, then again exit to close the command prompt.
B.10) On the screen, click the Refresh button. After a few seconds, your VHD should now appear in the list.
B.11) Select the VHD and click Next. (Note: A warning might be displayed at the bottom saying Windows can’t install to this drive. Ignore it!)
B.12) Continue to install Windows 8 as usual, following the on-screen instructions.

And you’re done! The whole Windows 8 OS is now contained within a single isolated file on your disk.
During the boot process, you will have the option to choose between your Windows 7 or Windows 8 installation. Simply select the OS you want to use!