How to dual boot your computer using a VHD in Windows 7
In a recent took a Windows 7 class at work and it showed me a cool feature that I didn’t know about and felt I should tell more people. Anyhow this feature of Windows 7 allows you to create a vhd and boot you computer. For thoughs that don’t know a vhd is Microsoft’s format for a virtual hard drive. So to do this correctly you will have to build your vhd using a Microsoft virtual tool such as Hyper V, Virtual Server 2005, Sysinternals disktovhd, or maybe Virtual PC. The cool thing about disktovhd is that the download is free and you simply install and convert a running machine into a vhd drive, you can’t get any easier than that.
Once you have your vhd built you can copy it over to the location on the machine you want it. From here there is just a few more steps. You can go to Disk Management and mount the vhd so it can be seen as a hard drive by the computer and you can access any of the contents. However this isn’t needed to boot from it. Here are some pics of the menus and procedures.
Right click on My Computer and select Disk Management. Then select attach VHD.
The browse for the location of the vhd you copied over to the computer.
Now it is mounted, mine is V: and can be accessed through My Computer. Not that you can boot now that it is mounted, but you can add files to the drive that you may want to install once it is booted.
Know comes the tricky part of the process. You will have to use a command line utility called bcdedit.exe. This utility will allow you to add a boot menu to the start up of the computer so you can select the vhd to boot from. In a command line window run as administrator, type in bcdedit /enum all. This will give you a look at all of the information that is contained in your boot file.
Now that we know what the boot menu looks like we can add the entries that will allow us to select the vhd to boot from. In the same command line enter bcdedit.exe /copy {current} /d “Name that will show up in the boot menu”. This creates a GUID for the install that you will need for the next commands. So run bcdedit /enum all again and find the name of the OS you enter in the previous command and write down or copy the GUID. Then you run bcdedit /set “Enter the GUID here” device vhd=[E:]\vhd7\windows7.vhd. You need to replace [E:] with the drive it is located on such as c: using [c:]. You will also replace “\vhd7\windows7.vhd” with the path to the vhd after the root of the drive. So if it is in c:\drive\files\ you will enter [c:]\drive\files\ and enter the name of the vhd. With that done you now need to enter bcdedit /set “your GUID” osdevice vhd=[your drive letter]\”your path to vhd”. Finally you enter bcdedit /set “your GUID” detecthal on.
You will see you entries in the boot menu if you run bcdedit /enum all once again. It should look similar to the following.
Then if everything was entered correctly, when you reboot the computer you should have a menu that allow you to select the OS to boot. It should look similar to the following pic.
I have only done this with Windows operating systems, I will give it a shot with Linux and see if I can get it to work as well. But this is a cool and easy way to boot computers into various operating systems using vhds. You can also boot it into multiple OS by putting them in the same location and renaming the vhd when you want to use it, or you can have 20 vhds setup to boot to each. I think this is very cool and makes dual booting very easy to do. Check it out and I will update on Linux booting.