Thursday, May 14, 2009

Dual booting Windows 7 and Windows 2008 R2 from a VHD

Creating Native Virtual Hard Disk (VHD) in Windows 7 -

This can be done with diskpart but on Windows 7 do it the easy way.

Right Click on My Computer and Click 'Manage' that will open up Computer Management, in that click on Disk Management.

Right Click on Disk Management and select 'Create VHD' This will open new windows 'Create and Attach Virtual Hard Disk'

In this windows select the location where you want to create the VHD file. Make sure you have sufficient free space while creating new VHD file. After that provide the Virtual Hard Disk size and format of the VHD.
By default the Fixed size is recommended but you can select Dynamic expanding if you don't want to allocate the disk space. There would be slight performance difference between fixed size and dynamically expanding.
For production environment it is suggested to go for Fixed size. For the demo purpose we will go ahead with dynamically expanding VHD format.

Click on OK and that will install newly attached (mounted) VHD. Now next step will be initializing the disk

Alright now Right Click on Disk 1 (Blue icon) and click on 'Initialize' This will open a new window 'Initialize Disk.'
Select the partition and click on 'OK.' You can leave the current selection to default.

As you can see now the status of the Disk 1 is changed to 'Online.' We create a new simple volume on the Disk 1

So Right Click on the 'Unallocated' area and select 'New Simple Volume' This will launch 'New Simple Volume Wizard.'
After that click on next and specify size, we will keep the default NTFS File System and select the complete size i.e. 20 GB and click on 'Next' to specify drive letter. I will select Drive Letter 'X:' and click on 'Next'
On the next page we will select Label for the drive (in this case 'Windows7') and click on 'Next.' Now, we will get the brief summary of the choices we selected. Click on 'Finish' to continue.

Booting a Windows 7 VHD or Windows Server 7 (aka Windows Server 2008 R2) VHD

To complete this section you will need a copy of Imagex this is a part of the Windows 7 WAIK You can download the WAIK for Windows 7 from here (This is in beta at time of writing so link may change)

From you windows 7 box mount your Windows 2008 R2 cd to a drive for the purpose of this article we will use the d:

From the path you installed imagex run the following command

imagex /apply d:\sources\install.wim 3 x:\ (x: is the mounted vhd you created earlier)

This will then apply the install.wim for Windows 2008 R2 enterprise edition to you mounted vhd

Adding the VHD Entry in Boot Menu and then Boot from VHD


Now that we have successfully created VHD files. The last step is adding boot entry for the VHD file in your Windows 7 or Windows Server 7 using BCDEdit.exe tool.


For this step open the Elevated Command Prompt with Administrator Privileges and type the following commands.
C:\>bcdedit /copy {current} /d "My New VHD Description"
Note: This will Return the GUID of the Loader Object that you will use to replace below

C:\>bcdedit /set device vhd=[driveletter:]\\

C:\>bcdedit /set osdevice vhd=[driverletter:]\\
C:\>bcdedit /set detecthal on

Run C:\>bcdedit /v to view your new config

If you want to delete any existing VHD entry from the Boot Menu you can always use the command C:\>bcdedit /delete /cleanup

Now detach you vhd from disk manager and your good to go.








1 comment:

Anonymous said...

Ahaa, its good discussion regarding this post at this place
at this web site, I have read all that, so now me also commenting here.
My site :: http://boligityrkia.net