Using Hyper-V in Windows 8

In Steven Sinofsky’s this blog – Bringing Hyper-V to “Windows 8”. He talks about that Windows 8 will support virtualization on the “client” OS.  This is very helpful for developers as they typically have the need to setup additional test environment on their PC/Laptop.

Hardware Requirements

Hyper-V supports creation of both 32-bit and 64-bit operating systems in VMs. To run Client Hyper-V, your computer must:

  • Be running a 64-bit version of Windows 8.
  • Have a CPU that supports Second Level Address Translation (SLAT), To determine if your CPU supports SLAT, go to How to tell if your CPU Supports SLAT

Enabling Client Hyper-V

  1. In the Windows 8 Control Panel, tap or click Programs, and then tap or click Programs and Features.
  2. Tap or click Turn Windows features on or off.
  3. In the Windows Features dialog box, select the check boxes for the Hyper-V items that you want to install, and then tap or click OK. image
  4. Tap or click Close.

Note: You must restart your computer to complete the Hyper-V installation. After restarting the computer, you can use Hyper-V Manager or Windows PowerShell to create and manage VMs. You can also use VM Console to connect to VMs remotely.

Enabling Client Hyper-V with Command Line Tool

  • Use Windows PowerShell. At the Windows PowerShell prompt (using administrator credentials), type the following:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V

  • Use the Windows Command Prompt. At the Windows command prompt (using administrator credentials), type the following:

Dism /online /enable-feature /featurename:Microsoft-Hyper-V –All

What Isn’t Included in Client Hyper-V?

Difference between Windows 8 Client Hyper-V and Server Hyper-V

Using SCVMM 2012 Cmdlets in PowerShell

SCVMM Cmdlets allow SCVMM admin/users to do everything they can do in SCVMM AdminConsole in windows PowerShell command line. In SCVMM 2008 R2, you can run following command in PowerShell to run SCVMM cmdlets.

Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager

But this does not work in SCVMM 2012 as SCVMM 2012 uses PowerShell module. For SCVMM 2012 now you need run following in PowerShell instead

Import-Module "C:Program FilesMicrosoft System Center 2012Virtual Machine ManagerbinpsModulesvirtualmachinemanagervirtualmachinemanager"

(This assumes that you have SCVMM 2012 installed on the default location C:Program FilesMicrosoft System Center 2012 )

The PowerShell cmdlets in SCVMM 2012 change a lot in SCVMM 2012, you can get a list of all SCVMM 2012 cmdlets by typing the following at the PowerShell command shell prompt

Get-Command -Module virtualmachinemanager -Type cmdlet

And you can run Get-Help on any of the cmdlets to get the syntax for that cmdlet.

Get-Help <cmdlet name> -detailed

Update: Microsoft has published the SCVMM 2012 cmdlets help to TechNet, check it out http://technet.microsoft.com/en-us/library/hh801697.aspx

Improve VM deploy performance in SCVMM

SCVMM use BITS over https to deploy virtual machine to host server. To improve the performance of virtual machine deploy, you can disable encrypted file transfers for Host Group.

  1. Open Virtual Machine Manager Administrator Console (aka SCVMM Console) on the Application Tier and connect to VMM Server
  2. Click Host on the left side pane.
  3. Right Click on All Host node, and select Properties.
  4. Select the check-box “Allow unencrypted file transfers”

Note: if you use library server, you should set Allow unencrypted file transfers for every library servers.

image

The same can be done in following SCVMM PowerShell command

Set-VMHostGroup -VMHostGroup “All Hosts” -AllowUnencryptedTransfers $true

HAL_INITIALIZATION_FAILED Error when install Windows 8 Developer Preview on VPC

When you install the Windows 8 Developer Preview on Virtual PC in 64-bit windows. Your installation would fail with the blue screen of sad:

: (
Your PC ran into a problem that it couldn’t handle, and now it needs to restart
You can search for the error online: HAL_INITIALIZATION_FAILED

image

Continue reading HAL_INITIALIZATION_FAILED Error when install Windows 8 Developer Preview on VPC

IDE/ATAPI Account does not have sufficient privilege to open attachment

You might get following error after you move or replace a virtual disk drive file of a hyper-v virtual machine.

An error occurred while attempting to start the selected virtual machine(s).

'TestVM' failed to start.
Microsoft Emulated IDE Controller (Instance ID
{83F8638B-8DCA-4152-9EDA-2CA8B33039B4}): Failed to Power on with Error 'General
access denied error'
IDE/ATAPI Account does not have sufficient privilege to open attachment
'D:VMTestVMTestVM.vhd. Error: ‘General access denied error'
Account does not have sufficient privilege to open attachment
'D:VMTestVMTestVM.vhd. Error: ‘General access denied error'

This is because the permissions on the new virtual hard drive (D:VMTestVMTestVM.vhd in this case) are incorrect. Here is the steps to fix this permission file.

  1. Open Hyper-V manager, Right click settings of the virtual machine
  2. Find the Virtual Hard Drive and choose “Remove”.
  3. Re-add the same Virtual Hard Drive back to the machine.
  4. Now start the VM again, it should boot successfully.

Could not load file or assembly TraceWrapper, Version=1.0.523.0

There are two versions of the TraceWrapper.dll in SCVMM install CD. One is x86 version and the other is x64 version. When you build your application on top of SCVMM library Microsoft.SystemCenter.VirtualMachineManager, it’s very important to pick up the correct version TraceWrapper.dll. In general, you should copy the 32 bit dll if you are using 32 bit system, copy 64 bit dll if you are using 64 bit system. Otherwise following BadImageFormatException would occur during runtime.

Could not load file or assembly ‘TraceWrapper, Version=1.0.523.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

However, you should keep using 32 bit TraceWrapper on a 64 bit system for following scenarios:

  • You need debug your app in Visual Studio directly. In this case, process launched from Visual Studio debugger runs in WOW64 mode.
  • IIS is configured to run in 32 bit mode. In this case, all working processes run in WOW64 mode.

This is because in 64 bit windows, processes in WOW64 mode are 32 bit processes and can’t load 64 bit TraceWrapper.dll.

Install Remote Server Administration Tools on Windows 7 SP1

Remote Server Administrator Tools (RSAT) is not compatible with Windows 7 SP1. If you install Remote Server Administration Tools on Windows 7 SP1 slipstreamed media, you will get following error.

The update is not applicable to your computer

That’s because current RSAT version only supports Windows 7 RTM. To workaround this issue, you can Install Remote Server Administration Tools before installing Windows 7 SP1. The SP1 upgrade will update RSAT to SP1 version. The other option is wait for official release of Remote Server Administrator Tools for windows 7 SP1, which will happen this April.

Update 4/8/2011: Microsoft released Windows 7 SP1 RSAT Tools to public today. The download link is here http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7d2f6ad7-656b-4313-a005-4e344e43997d

Windows Server 2008 R2 SP1 New Features

Other than rolls up all previous released windows patches since RTM, Windows Server 2008 R2 SP1 contains two new features. Dynamic Memory and RemoteFX.

Dynamic Memory

Dynamic Memory is a memory management feature for Hyper-V VM administrators. Dynamic Memory allows administrator allocates a range of memory to indivual VMs and windows system will automatically adjust memory of each VM based on performance.

RemoteFX

RemoteFX creates a local like experience for remote users, including windows Aero and 3D contents.

You can read more about SP1 from Windows 7 Team Blog

Find Physical Host Name of a Virtual Machine

 

If the virtual machine is hosted on a Windows Server with Hyper-V and has Integration Service installed, you can look at following virtual machine’s registry to identify the physical host machine.

HKLMSoftwareMicrosoftVirtual MachineGuestParametersPhysicalHostName

 

If you use PowerShell, here is a one line script that can indicate host name.

(Get-Item "HKLM:SOFTWAREMicrosoftVirtual MachineGuestParameters").GetValue("PhysicalHostNameFullyQualified")

Hyper-V VM Slow on Windows Server 2008 R2

I recently upgraded my virtual machine hosting server from Window Server 2008 to Windows Server 2008 R2. There are some noticeable performance drop, especially on virtual machines that handles big log files, the automation script execution time can take 200% or more than it was in a VMHOST with Windows Server 2008.

I have done some testing and the performance downgrade seem introduced by the new power management system in windows server 2008 R2. There are 3 build in power plan in Windows Server 2008 R2

  • Balanced (recommended)
  • High Performance
  • Power Saver

The default power plan in Windows Server 2008 R2 is Balanced. After I change Power Plan to High Performance and the performance downgrade issue does no occur any more. My guess is when power plan is set to balance, applications might not full utilize all available hardware resources.

You can also checkout this post for Set the power configuration to High Performance in scripts.