Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


February 10, 2009

Q. How can I install Windows 7 or Windows Server 2008 R2 to a virtual hard disk (VHD) file?

RSS
Subscribe to Windows IT Pro | See More News and Analysis Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

A. Windows 7 and Server 2008 R2 add the ability for an OS to be installed onto a virtual hard disk (VHD) file to boot physical hardware. To do this, perform the following steps:

  1. Boot from the Windows 7 or Server 2008 R2 media.
  2. Select language options and click Next.
  3. At the Install Now screen, press Shift and F10 simultaneously to open a command prompt window. You'll partition the disks and create your VHD file in this window.
  4. Select the disk and wipe all of its existing content using the following commands.
    diskpart
    list disk
    select disk 0
    clean
  5. Create a 200 MB system partition using the following commands. The Windows 7 and Server 2008 R2 installation procedures normally create this partition automatically.
    create part primary size=200
    format fs=ntfs label="System" quick
    active
  6. Create a partition using the rest of the space on the disk. This partition will hold the VHD files. I call the partition Boot, but you can call whatever makes sense for you. Also, I've used the C drive, but when you boot to the VHD the drive letters will shift. If you assign a different letter, make sure to use the new letter in step 7.
    create part primary
    format fs=ntfs label="Boot" quick
    assign letter=C
  7. Create a VHD file on the C drive. In this example, I've created it as a 25 GB file that is an expandable disk. You can use "type=fixed" instead of "type=expandable" to create a fixed-size VHD. A fixed-size VHD will use space on the physical disk equal to its full size as soon as the VHD is created but will give better performance, so I recommend fixed-size disks for uses other than testing.
    create vdisk file=c:\win7ult.vhd maximum=25000 type=expandable
    select vdisk file=c:\win7ult.vhd
    attach vdisk
    create partition primary
    format fs=ntfs label="Win7Boot" quick
  8. You can now list your volumes with the command
    list vol
    An example list is shown here.

    Click to expand

  9. Exit Diskpart and close the command prompt window by entering the "exit" twice.
  10. Proceed with the installation. When you're asked to select the installation target, choose the VHD partition you created. The installer will warn that you cannot install it on the partition, but you can ignore the warning.

    Click to expand

Installation will now progress as usual. Once installation is finished, you can see that the VHD partition is now the C drive while the partition containing the VHD files is demoted down to the D drive, as shown here. If you look at the contents of the drives, you'll see D contains the VHD file and C, the content of the VHD, looks like a standard drive with a Windows installation. The 200 MB partition you created doesn't have a drive letter and is essentially invisible to the OS.

Click to expand



Booting from a VHD is explained in the following video.


Related Reading

Videos:

Audio:


Check out hundreds more useful Q&As like this in John Savill's FAQ for Windows. Also, watch instructional videos made by John at ITTV.net.

End of Article



Reader Comments
cool many thanks.

will give it a go soon

ra@ix.net.au February 10, 2009 (Article Rating: )


I have installed Win7 in a VHD (expandable, size 75 Go) This all went ok.
I'm trying to create a second VHD (Win7R2, fixed, 100 Go) but it doesn't want to install.
What do I have to do to install both Win7 and Win7 Server R2 in 2 VHDs located on the same hard drive ?

When trying to install on this second VHD called Win7R2.vhd, It's showed as Disk 2 Partition 1 and the installer tells me that Windows cannot be installed to Disk 2 Partition 1.
When clicking on Show Details, I have the following explanation :
This computer's hardware may not support booting to this disk. Ensure that the disk's controller is enabled in the computer's BIOS menu.
I don't understand this error as I already installed Win7 in the other VHD... located on the same hard drive.
Could anyone help me ?

Thanks

CGirardy February 23, 2009 (Article Rating: )


..... It's working now, I don't know what happened. :)

CGirardy February 23, 2009 (Article Rating: )


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Battery Life Issues Almost Certainly Not Windows 7's Fault

While Microsoft is still investigating a notebook battery life issue that was supposedly caused by Windows 7, some interesting trends have emerged. ...

Confirmed: Battery Life Issues Not Windows 7's Fault

Microsoft on Monday issued a lengthy statement about the recent Windows 7 battery controversy, echoing my assessment from earlier in the day, but backing it up with hard, cold evidence. ...

Getting your iPhone to Sync with Exchange 2003

Follow these steps to use an iPhone with Exchange. ...


Related Events VirtualizationPro 2010 Summit & Expo

SQL Server Virtualization for Performance and Security

Reduce Fax Costs by Virtualization

Check out our list of Free Email Newsletters!

News and Analysis eBooks Getting Maximum Performance from Your Web-based Applications

Business Process Automation - Managing Cost in Your Enterprise

Understanding and Leveraging Code Signing Technologies

Related News and Analysis Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2010 Penton Media, Inc. Terms of Use | Privacy Statement