Here is a concise “how to” note from the field describing the essential steps to setup direct booting of the RTM versions of Windows 7 and Windows Server 2008 R2 from a virtual hard disk (VHD). Unless otherwise stated here, Windows refers to Windows 7 and Windows Server 2008 R2 since this new feature is exclusive to both OS.
The assumption here is that you have already installed either Windows 7 or Windows Server 2008 R2 in a real partition on the physical machine itself. This dependency is necessary to make use of this capability in the updated OS Boot Loader. You should be using an elevated administrative account to run the commands shown.
Step 1 - Install Windows Automated Installation Kit for Windows 7 and Windows Server 2008
1.1 boot Windows from a physical partition
1.2 download and install WAIK in the host Windows machine. You will need the imageX executable that is part of this kit.
Step 2 - Create the VHD
2.1 create a VHD (via Disk Management snap-in, diskmgmt.msc, Action / Create VHD) - recommended to build a fixed size VHD sufficiently large to hold the OS and any other applications e.g. 30GB
2.2 supply the full path and filename or browse to a folder and type in the name e.g. G:\vm\vw7.vhd; otherwise it will fail with the message:
Virtual Disk Manager
The pathname for a virtual disk must be fully qualified
2.3 right-mouse click on the newly created basic Disk N (1, 2, etc.), Initialize Disk and select either MBR or GPT as the preferred partition style then click OK.
2.4 on the unallocated disk, right-mouse click to create a simple disk volume (using the whole disk or make partitions), assign a drive letter (say drive G:) and perform a quick format (NTFS and default allocation unit size). The result is that the disk will be set to Online.
Step 3 - Prepare the VHD
3.1 insert the source Windows DVD or mount the ISO as a drive
3.2 start Microsoft Windows AIK / Deployment Tools Command Prompt and run:
imagex /info <cd_rom:>\sources\install.wim
3.3 identify the target image under Available Image Choices using keywords such as:
<WIM>
…
<IMAGE INDEX=”5″>
…
<PRODUCTNAME>Microsoftr Windowsr Operating System</PRODUCTNAME>
<EDITIONID>Ultimate</EDITIONID>
…
<DISPLAYNAME>Windows 7 Ultimate</DISPLAYNAME>
<IMAGE>
</WIM>
3.4 extract the Windows image to the VHD via:
imagex /apply <cd_rom:>\sources\install.wim 5 G:\
where 5 = index of OS, G = mounted drive letter
Step 4 - Modify the Boot Menu
4.1 use BCDEDIT to run the commands as depicted where { - - - - } is the GUID Loader Object returned from the first statement:
bcdedit /copy {current} /d “VHD - Windows 7″
bcdedit /set { - - - -} device vhd=[G:]\vm\vw7.vhd
bcdedit /set { - - - -} osdevice vhd=[G:]\vm\vw7.vhd
bcdedit /set { - - - -} detecthal on
4.2 execute this statement to verify that the changes have been made:
bcdedit /v
4.3 use Disk Management to detach the VHD then reboot the host machine.
4.4 select the newly created entry from the menu to boot Windows from VHD. The remaining process from this point onwards is similar to running Windows setup on a physical box (but faster) to prepare your computer for first use.
Hardware devices will be discovered and available drivers will be installed with no apparent differences from running Windows from a real disk partition e.g. plug-and-play auto detects video display/Aero, network adapters (fixed and wireless), USB, built-in Webcam, etc. Subsequently, you should run Windows Update and click “Get updates for other Microsoft products. Find out more” to locate updates for items like missing drivers, important and optional updates.
With Disk Management, you will discover that Windows was booted from the VHD identified as Disk 1 (Basic 30.00 GB Online) with %systemdrive% assigned as C:. This particular device does not actually exist as a physical entity; it refers instead to G:\vm\vw7.vhd of the type “Msft Virtual Disk SCSI Disk Device” on Location 1 (Bus Number 0, Target Id 0, LUN 1) in our setup here. Compare to a typical setup on a real box, you will not find a 100MB partition named System Reserved automatically set aside by Windows for future BitLocker deployment purposes.
The real Disk 0 will display the properties Location 0 (Channel 0, Target 0, Lun 0) regardless of how many primary/logical partitions there are. You will continue to have full access to the latter partitions via distinct drive letters as seen by the (booted) host OS.
You should be able to repeat the steps outlined here to create as many VHDs as you need to boot from your favorite versions of Windows (7 and Server 2008 R2). Did you find this post useful? Comments and feedback welcome - enjoy!
References:
Windows 7 VHD Boot Demonstration
Technorati tags: Windows Server 2008 R2, Windows 7 Client