Thursday, May 14, 2009

Creating a Hyper-v R2 Lab

The plan

My goal was to build a home lab to test out some of the new cool features in Hyper-v 2.0 such as Live Migration and Processor Compatability mode.

To do this I created a shared storage environment and a 2 node failover cluster with different processors (Same family AMD).

The kit:
Hp desktop pc vista(This will host the Shared Storage server)
Custom Built machine (Node 1) AMD-V support
Hp dv9000 laptop (Node 2) AMD-V support



The story so far

Shared Storage


I Downloaded and installed Starwind on my vista laptop. The reason im using Starwind as my ISCSI target rather than something like openfiler or FreeNas is that Starting with Windows 2008, the cluster software requires your iSCSI target software to support something called "persistent reseration commands". These are based on the SCSI Primary commands-3 specs (SPC-3), and most open source software (with the possible exception of OpenSolaris) is based on SCSI-2, and does not support these reservation commands.

Note once installed create a firewall rule to allow tcp port 3260. I created 2 iscsi targets located on a usb attached external 1 terabyte disk. Needless to say this is for lab purposes only.

On Nodes 1 and 2 I installed Windows 2008 R2 enterprise eddition.

For the low down details have a look at my lab step by step.

The Lab

http://sites.google.com/site/alexcrawford/Home/Hyper-VLab1InstallingHyper-V2NodeCluster.pdf?

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.