Share via


Building a Win7/2008 R2 box that boots off .vhd's

A cool new feature in Windows7 & Server 2008 R2 is the ability to boot from a .vhd file!

Having your OS isolated to a .vhd file has a number of advantages including but not limited to:
- easier to backup,
- multi-boot scenarios that are more isolated from each other,
- ability to trial new builds on your physical hardware without trashing your existing installation.

Whilst there's a variety of ways that boot from .vhd can be achieved, here's the steps I've used.  Note, I deliberately tried to avoid the installation GUI by doing part of the install via the WinPE command line.  It's possible to automate the remainer of the installation process via an unattend.xml file.  However, that's a potential topic for a future blog post.

1) Install the Windows AIK.

Windows® Automated Installation Kit (AIK) for Windows® 7 RC
https://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=60a07e71-0acb-453a-8035-d30ead27ef72

2) Create bootable WinPE media (DVD or USB key) and include imagex.exe from the AIK on it.

Windows PE Walkthroughs
https://technet.microsoft.com/en-us/library/dd799278(WS.10).aspx

3) (optional) Include the install.wim from your desired Windows installation media on your WinPE media.  Alternatively, I suppose you can always refer to the original installatiom media instead.

4) Boot off your WinPE media then run the following DISKPART commands (possible to script this via DISKPART /s)

select disk 0
clean
create partition primary size=100
format quick fs=ntfs label=System
assign letter=s
active
create partition primary
format quick fs=ntfs label=Data
assign letter=d
create vdisk file=d:\win7rc.vhd type=fixed maximum=10240
attach vdisk
select disk 1
create partition primary
format quick fs=ntfs label=OS
assign letter=c
exit

5) Extract the Windows image to your .vhd and copy the necessary boot file to your system partition.

imagex /apply w7rc_x86.wim 5 c:
bcdboot c:\windows /s s:

*** START OF UPDATE 7-Aug-2009 ***

You *might* need the following also. I don't recall doing this when I originally posted this however I needed this in a recent attempt. 

bcdedit /store drive: \boot\bcd /set {guid} device vhd=[locate]\win7rc.vhd

bcdedit /store drive: \boot\bcd /set {guid} osdevice vhd=[locate]\win7rc.vhd

 

Where drive: is the system partition.

*** END OF UPDATE 7-Aug-2009 *** 

exit 

Your system will reboot and proceed with installation.  For those that are keen to automate the remainder of the installation, here's a link to the relevant info:

Step-by-Step: Basic Windows Deployment for IT Professionals
https://technet.microsoft.com/en-us/library/dd349348(WS.10).aspx

Comments

  • Anonymous
    May 22, 2009
    The comment has been removed