Monday 21 February 2011

Booting from Virtual Hard Drives (VHDs) with Windows 7

The reality is that many of us need more the one OS and virtualization is not always the best answer. Booting from a VHD can give you the choice of many operating sytems without having to have a myriad of partitons on your machine. I will show you how in the article.

So I choose to install Windows 7 on my laptop with a single partiton. Windows 7 will be my main client operating system; however I will want other Windows 7 configurations and Windows Server configurations. Yes I can use virtualization but I have found that sometimes the performance is not quite there when I do not have a fast drives, fast memory and CPU cores that you may find in a data-centre and, on some occassions, I will need Virtual Server Configurations within my Virtual Machines which is never the most effective solution.

To allow me some flexabilty I want to boot nativerly to the extra OSs that I need. I can do this with Virtual Hard Drives, (VHD ). To ccreate the VHDs either upicsn use Dispart or the Windows 7 Graphical Disk Mananager. In the video demonstrations I have choosen to use the command line and dispart.exe, ( well I am a command line freak ). Once you have created your VHD you can use imagex from the WAIK toolbox to install the install.wim file from you required operating system installation disk. ( [DVD]:\sources\install.wim ). This is a great feature as it allows the you to omit the need for the installation: just image it.
  • imagex /info d:\sources\install.wim
  • check for your index number of the OS you need
  • imagex /apply /check 3 d:\sources\install.wim x:\
  • in this case we are using index 3 from the image file , x: being the drive letter of our VHD.
Now if you check the contents of the VHD ( as above drive x:\ ) it will look an OS drive , cool we are ready now to detach the VHD and add it to our boot menu. You will need to open your command prompt with administrative privileges. With that in place then the process of writing to the Boot Menu is reasonbly easy once you know what is happening. Although it id by no means a simple edit like the boot.ini you may be used to.
  • bcdedit /copy {current} /d “Boot VHD”
  • Create a new clone entry of your current OS with a description of “Boot VHD”
  • bcdedit
  • use the command on it’s own to view the new guid of the boot entry you have just created
  • bcdedit /set {GUID} device=[c:]\vhd\boot.vhd
  • bcdedit /set {GUID} osdevice=[c:]\vhd\boot.vhd
  • bcdedit /set {GUID} detecthal on
And there you are just reboot now to test. Hope this is useful to you and have a look at the demo below:
Create the VHD

No comments: