To install Windows 8 to a VHD is very simple. Start a clean install process for Windows 8 but stop when you are asked "Where do you want to install Windows?". See the image below:
Now you have to attach a VHD file to the installer. Windows 8 will recognize it as a valid location for OS installation. Here's how to proceed next:
1. Hit the key combination "Shift + F10" on the keyboard and a Command Prompt window opens up.
2. In the Command Prompt window, type diskpart followed by "Enter".
3. Select the VHD file you created earlier. I order to do this, you have to know the path to the VHD file. On a typical Windows 7 installation there are two primary partitions: a visible partition which hosts the operating system and other files and a hidden partition for boot and recovery tools. When Windows is running, it assigns the letter "C" to the visible partition. When the installer is running, you have to pay attention because the boot partition is not hidden and it is assigned the letter "C". The letter "D" is assigned to the main partition hosting OS and files.
Example: If the VHD file was created in C:\VHD\Win8.vhd while Windows was running, you have to adjust the file path to D:\VHD\Win8.vhd when in the install mode.
Now run the following command: select vdisk file=d:\vhd\win8.vhd
4. Now type attach vdisk then "Enter".
5. Close the Command Prompt window and hit "Refresh" on the previous screen.
6. Select the new VHD drive listed as "Drive 1" and hit "Next". Ignore the warnings that might appear and continue the installation of Windows 8 as usual.
When you restart the PC, you will be allowed to choose between Windows 7 and Windows 8 in the boot menu. See the image below: