Category Archives: System Center Virtual Machine Manager

Hyper-V Virtual Machine Connectivity Issue

Following an issue with the storage used by our Hyper-V cluster, one node in our five node cluster became partially unresponsive.  The virtual machines (VMs) running on the unresponsive node were automatically moved to other cluster nodes and service was resumed withing a couple of minutes.  At first everything appeared to be fine, but within a few minutes our monitoring system started to report connectivity issues to the VMs that had failed over.

I RDP’d onto one of the VMs that was having connectivity issues, but found the connection kept dropping out, so I connected to the console through System Center Virtual Machine Manager (SCVMM).  I found I was unable to ping any server on the physical network.  I took a look at the event log on one of the virtual hosts and saw the error below:

Port ‘BF392932-9AE4-453A-8E13-26671BB556D9′ was prevented from using MAC address ’00-14-22-18-7F-DC’ because it is pinned to port ‘SCVMM-C26227E3-D6AB-4818-B8BF-4CCF923C’.

The error message implied another VM was using the MAC of the VM that was having connectivity issues.  As the VM had a dynamic MAC that was managed by SCVMM I knew that couldn’t be the case.  I decided to reboot the unresponsive cluster node.  After waiting 30 minutes for the node to shutdown I killed the power via a DRAC.  As soon as I killed the power to the node the MAC address errors in the event log disappeared and all the VMs resumed normal connectivity.  I believe the cluster node that became unresponsive was keeping some kind of lock on the MAC addresses of the VMs that were running on the node when it became unresponsive.  Killing the power to the node freed the locks enabling connectivity to resume.

Deleting Hyper-V Snapshots

An important point when deleting a Hyper-V snapshot is that the corresponding AVHD file isn’t merged into the main VHD file until you power down the server.  This means that the disk space used by the snapshot isn’t immediately available when you delete a snapshot.

As far as I’m aware there’s no way to monitor the merge process through System Center Virtual Machine Manager, but you can via the Hyper-V MMC.

If you start a virtual machine during the merge process, the merge process stops and the machine starts instantly.

 

 

 

PXE Boot a Virtual Machine In Hyper-V 2008 R2

PXE boot is not available in Hyper-V 2008 R2 when using a Synthetic Network Adapter.  In order to PXE boot a virtual machine (VM), you need to turn off the VM and add a Legacy Network Adapter.  If the VM is an existing machine with a bootable hard disk, you’ll also need to change the boot order, so PXE Boot is above IDE Hard Drive.

Reporting Virtual Machine Dynamic Disk Space Using PowerShell And System Center Virtual Machine Manager 2008 R2

Dynamically expanding disks enable you to thin provision virtual machines (VMs)  storage.  This means you can pack more VMs onto a given amount of disk, but you need to ensure that if you provision more storage than is physically available, you don’t run out of space on the host.  The PowerShell script below produces a csv file showing the space available for growth on each VM with a dynamically expanding disk.  You can use this script to see how much space could still be used by your VMs and therefore see if you’re likely to run out of space on the host.  It’ll also show you if a dynamic disk is about to reach it’s maximum size.

Load PowerShell from the icon in the SCVMM console

Next copy and paste the code below into the PowerShell console, replacing VMMHOST with the name of your SCVMM host and the path of the csv file as appropriate.

Get-VirtualHardDisk -VMMServer VMMHOST -All | Select-Object @{Label=”VM Host”;Expression={$_.VMHost}},@{Label=”Name”;Expression={$_.Name}},@{Label=”Space To Grow”;Expression={[Math]::Truncate(($_.MaximumSize-$_.Size) / 1GB)}},@{Label=”VHDType”;Expression={$_.VHDType}} | Where-Object {($_.VHDType -Match “DynamicallyExpanding” -And $_.Name -NotMatch “{“)} | Sort-Object “Space To Grow” -Descending |  Export-Csv C:\DiskInformation.csv

Opening the csv in Excel produces

 

The PowerShell script is a one liner and breaks down as follows:

Get-VirtualHardDisk -VMMServer VMMHOST -All | Gets the virtual disk for the VMMServer specified

Select-Object @{Label=”VM Host”;Expression={$_.VMHost}},@{Label=”Name”;Expression={$_.Name}},@{Label=”Space To Grow”;Expression={[Math]::Truncate(($_.MaximumSize-$_.Size) / 1GB)}},@{Label=”VHDType”;Expression={$_.VHDType}} | Selects the VM host name, disk name, calculates the maximum disk size – current disk size and converts to GB, VHD type

Where-Object {($_.VHDType -Match “DynamicallyExpanding” -And $_.Name -NotMatch “{“)} | Filters the results to only include dynamically expanding disks whose names don’t start {

Sort-Object “Space To Grow” -Descending | Sorts the output by space to grow, descending

Export-Csv C:\DiskInformation.csv Exports the results to a csv file

 

Retrieving A List Of VMs With Checkpoints In System Center Virtual Machine Manger 2008 R2

If you’re using System Center Virtual Machine Manger 2008 R2 (SCVMM) and need a list of virtual machines with checkpoints, you can do this with a simple PowerShell command.  From within the SCVMM console click on the PowerShell icon (see below) and run the command: Get-VMCheckPoint .  Further information about the Get-VMCheckPoint command is available by running: Get-help Get-VMCheckPoint

Removing Failed Machines from System Center Virtual Machine Manager 2008 R2

Following an issue with our five node Server 2008 R2 Hyper-V cluster I was left with two entries for one virtual machine (VM) in System Center Virtual Machine Manager 2008 R2 (SCVMM).  One entry listed the VM as running, the other as failed, despite the fact that there was nothing wrong with the VM.  I was unable to remove the failed entry for the VM using the SCVMM GUI, so used the steps outlined in this KB article http://support.microsoft.com/default.aspx?scid=kb;EN-US;983839 This article is for removing missing VMs, rather than failed ones, so I altered the SQL that is run in step 5.  First I ran the SQL below to retrieve the object state of the failed VM

SELECT ObjectState
FROM dbo.tbl_WLC_VObject
WHERE Name = ‘VMName’

I then ran this code to ensure that I wasn’t going to remove any other VMs.  Only the failed VM should be returned by the code below.  Change the ObjectState value to the value returned by the code above

SELECT Name
FROM dbo.tbl_WLC_VObject
WHERE ObjectState = X

As only one VM was returned, I updated the code at the beginning of step 5 of the KB article and replaced the ObjectState value of 220 with the ObjectState for my failed VM.  I also applied the hotfix here http://support.microsoft.com/kb/2308590 to guard against similar future issues.