Wednesday, November 27, 2013

Configuring Management VLAN in Hyper-V 2012 Core using Powershell

While configuring some Hyper-V 2012 core servers this week, I came across a bunch of issues trying to configure VLAN tagging on the management network. My goal was to configure the environment as follows:

Switch Port Configurations:
-2 ports to the Hyper-V host
-trunk ports
-native VLAN 1
-Management VLAN 28
-various other VLANs for VM traffic

Hyper-V Host Configurations:
-NIC Teaming
-Host IP on management VLAN
-1 VMswitch

Once the OS was installed and all the drivers were added, begin by teaming the NICs. Since there is no GUI in Hyper-V core, copy LbfoAdmin.exe and LbfoAdminLib.dll onto the server and run the executable to team the NICs.

Next, open up a command prompt. Identify the name of the virtual adapter for your NIC Team:

Create the VMswitch:
New-VMSwitch -AllowManagementOS 0 -Name "vSwitch" -NetAdapterName "<VirtualAdapterName>"

Create a management adapter and add it to the newly created VMswitch:
Add-VMNetworkAdapter -ManagementOS -Name "Management" -SwitchName "vSwitch"

Tag the VLAN ID to the management adapter:
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName "Management" -Access -VlanId 28

Configure the IP of the management adapter:
New-NetIPAddress -InterfaceAlias "vEthernet (Management)" -IPAddress x.x.x.x -PrefixLength # -DefaultGateway x.x.x.x

The management interface should now be pingable.

Credits to Eric Siron.

Thursday, November 7, 2013

No visble datastores after storage failure

Last night there was a failure in our SAN in the QA/Test VMware environment. Upon bringing the SAN back online, I observed that all the datastores have been removed from the hosts. My first thought was that this was not an complicated issue - all I would have to do is restart the hosts and when all the paths have been re-established, do a rescan for the datastores and all would be well. Unfortunately after restarting the hosts, the datastores did not come up even though I can clearly see all the paths to the LUNs. Here is a summary of the symptoms:

  • Datastore do not show up after rescanning HBAs and VMFS even though all the paths are there
  • Trying to add a new datastore will show all the LUNs, but attempting to add the datastore while preserving VMFS signatures results in an error
  • VMs all show up as inaccessible
  • LUN numbers appear to have been changed on the storage

The last point regarding the LUN number change was the crucial finding. After a bit of googling, it appears that you would need to manually remount the datastores. Here's how to do it via vCLI.

First, get the host object for the affected host (you'll have to do it one at a time or combine the following commands in a script).

$esxcli = Get-EsxCli -VMHost "vm-host1.local"

Next, list the datastores it has detected that has been unmounted.


The list of datastores should now be displayed. Mount each of them using the following command.


Repeat this process for all the affected hosts and all your datastores should be properly mounted and working again.