Install Windows7 or Windows Server 2008 into a VHD

I am one of many developers who wants to be prepared for Visual Studio .NET 2010 and SharePoint 2010. For evaluating purposes it’s easy to use virtual machines. However you can create virtual machines with Virtual PC, it doesn’t allow you to create 64-bits instances. So, how to create one especially for Windows Server 2008 R2 which is only 64-bits?

With Windows7 and Windows Server 2008 you can boot from a VHD file. Cool. But we need one. The answer is to install Windows directly into a VHD! Possible? Yes!

The steps are:

  • Boot from DVD
  • When the first Window is appearing, asking for the regional settings, just press SHIFT-F10. This opens a command prompt.
  • Start DISKPART. With this Disk Partition Tool you can also create a VHD file.
  • Enter: CREATE VDISK FILE=d:vhdWindows7x64.vhd TYPE=fixed MAXIMUM=20000

With this statement you create a VHD file with a fixed size of 20Gb. If you don’t want to have a fixed file, you can set TYPE = EXPANDABLE. You’re free to choose you’re own location. In this example I use D:VHD to store all my VHD files.

  • Enter: SELECT VDISK FILE=d:vhdWindows7x64.vhd
  • exit DISKPART and exit the Command Prompt.
  • Continue the Windows installation and when the screen asks on what partition to install Windows, you can now select the newly created VHD! And yes, you will get a warning that Windows cannot be installed on that partition, but you can ignore it.

The installation will take care of modifying the boot configuration. The new installation will be the default item to boot from.