ESXi – How to list OS discrepancies

As VMs get upgraded to newer OSes the VM Guest OS setup on the ESXi hosts migth no longer be the same as the OS version the VM is running (i.e. VM got upgraded from Win 7 to 10 but ESXi host still thinks it is running 7).

Here is a one liner that shows what is set and what is actually there:
Get-View -ViewType "VirtualMachine" -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Where-Object {($_.Config.GuestFullName -ne $_.Guest.GuestFullName) -and ($_.Guest.GuestFullName -ne $null)} | Select-Object -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}}, @{N="Running OS";E={$_.Guest.GuestFullName}} | Format-Table -AutoSize

The output look something like that:

Name                                  Configured OS                       Running OS
----                                  -------------                       ----------
win2K                                 Microsoft Windows 2000 Server       Microsoft Windows 2000 Professional
RH3                                   Red Hat Enterprise Linux 3 (32-bit) Red Hat Enterprise Linux 3 (64-bit)
suse51                                SUSE Linux Enterprise 11 (64-bit)   SUSE Linux Enterprise 12 (64-bit)

Debian – VMware Tools

Open VM Tools

Open VM Tools is the open source implementation of VMware Tools and consist of a suite of virtualization utilities that improves the functionality, administration, and management of virtual machines on VMware hypervisors. VMware recommends using the Open VM Tools redistributed by the operating system vendors. For additional information, see knowledge base article 2073803, VMware support of open-vm-tools, at http://kb.vmware.com/kb/2073803.

Install Open VM Tools

  1. Add the following line to the /etc/apt/sources.list file.
    deb http://ftp.debian.org/debian/ wheezy main contrib
  2. Run the commands:
    $ sudo apt-get update
     $ sudo apt-get install open-vm-tools

Source: vmware.com

How to find virtual machine name from a MAC address using PowerShell

Stating the obvious:
1. you need vCenter server
2. you need to be connected to your VC server from PowerShell

To get the VM name from MAC address just run this command
get-vm | Get-NetworkAdapter | where {$_.macaddress -eq "00:50:56:b4:3d:12"} | select parent,macaddress

or save this as a script i.e. get-VMfromMAC.ps1
$mac = Read-Host "What mac address do you want to lookup (format:11:22:33:44:55:66 )"
get-vm | Get-NetworkAdapter | where {$_.macaddress -eq "$mac"} | select parent,macaddress

Linked Clones on ESXi 5.5

1. Run sysprep and reseal the VM for cloning. Shut it down when finished and do not turn it on.

2. Install PowerCLI

3. Get the script: http://poshcode.org/1549 :

param (
 [parameter(Mandatory=$true)][string]$SourceName,
 [parameter(Mandatory=$true)][string]$CloneName
)
$vm = Get-VM $SourceName
# Create new snapshot for clone
$cloneSnap = $vm | New-Snapshot -Name "Clone Snapshot"
# Get managed object view
$vmView = $vm | Get-View
# Get folder managed object reference
$cloneFolder = $vmView.parent
# Build clone specification
$cloneSpec = new-object Vmware.Vim.VirtualMachineCloneSpec
$cloneSpec.Snapshot = $vmView.Snapshot.CurrentSnapshot
# Make linked disk specification
$cloneSpec.Location = new-object Vmware.Vim.VirtualMachineRelocateSpec
$cloneSpec.Location.DiskMoveType = [Vmware.Vim.VirtualMachineRelocateDiskMoveOptions]::createNewChildDiskBacking
# Create clone
$vmView.CloneVM( $cloneFolder, $cloneName, $cloneSpec )
# Write newly created VM to stdout as confirmation
Get-VM $cloneName

 

I have got it saved as Create-LinkedClone.ps1

4. start PowerCLI, connect to your vCenter server and run the script:

You can also run this:

And here is a screen dump of my vCenter server with the Clone:

Now let’s start up the Clone:

Sysprep will take us through the setup.

Creating iSCSI multipath IO network in vSphere v5 with ReadyNAS as a storage

The objective is to setup MPIO iSCSI connection between VM host running ESXi v5 and a ReadyNas 3200 storage.

ReadyNAS NIC Setup

Make sure teaming is disabled on all interfaces. Set IP addresses:
next step – setup iSCSI targets:
Open your ReadyNAS frontview.
Select Volume | Volume Settings | Volume C | iSCSI
Enable iSCSI support and click Apply
Select Create iSCSI Target
Enter the target name and capacity.  I believe 2000 GB is the max for the ReadyNAS.  Select Create.
OK through the confirmation windows.  We will set access control once we get the iSCSI initiator configured on the ESXi host.

Switch setup

non required

VM host setup

Verify your NIC’s in VSphere
Select the host | Configuration | Network Adapters

Create a vSwitch for the NIC’s.

We will be associating each vmnic with a vmKernel port:

Select your EXSi host | Configuration | Networking | Choose Add Networking:

Select  your NICs (vmnic2 & 3 in my case) – click NextThen enter a name in the Network Label box (vSwitch2) – click Next and Finish.Now go into the Properties of the vSwitch:

Now we need to  assign 1 NIC on each of the vmKernel ports. Select the first vmKernel port and click Edit:
Select NIC teaming and check Override switch failover order. We mus have only 1 vmnic active.
Do this for the remaining vmnic(s)

Testing

SSH into the ESXi host and attempt to ping all ReadyNAS IP addresses using vmkping command

ESXi 5 iSCSI initiator

By default ESXi 5 does not have the iSCSI Software Adapter loaded.
Select the ESXi host | Configuration | Storage Adapters | Add

Now select the iSCSI storage adapter and select properties.
Copy the name into your clipboard.  So we can paste it into the access control list on the ReadyNAS LUN.






Open your ReadyNAS frontview.  Select Volumes | Volume Settings | Volume C | iSCSI
Select your Target and the configure “gear” for the LUN.

Now back to the ESXi host.
On the iSCSI Initiator select network configuration. And add all of the vmkernel groups iSCSI1, iSCSI2

Select Dynamic Discovery and add your target.  Only add one IP for your ReadyNAS



Select the Static Discovery tab and all 2 paths should be shown:

Go to Configuration | Storage
And you should see your LUN.

Right click on the LUN and choose properties.

Select Mange Paths

By default ESXi is set to Most Recently Used (VMware).  So we have 2 nic’s but only 1 will be used.  We need to change the path selection to Round Robin.

Select round robin from the drop down press change.  Now you will see all 2 adapters are set to active i/o.  Press Close.


Final tweaking

By default, VMware has set a limit of 1000 IO’s to travel down each path before switching to the next path. However by changing that default down to 1 IO before switching paths we can sometimes achieve much greater throughput because we can more effectively utilize our links.

Enable the SSH console on your ESXi 5.0 host.

The command for ESXi5 is:
esxcli storage nmp psp roundrobin deviceconfig set -d naa.devicename --iops 1 --type iops

and to get the device name you could use:

esxcli storage nmp device list | grep naa.600



To verify, enter the following command to verify:
esxcli storage nmp device list 

You should see the following string showing IOPs now equal to one!
t10.F405E46494C45425F4D614162357D2354745A4D295162773
Device Display Name: OPNFILER iSCSI Disk (t10.F405E46494C45425F4D614162357D2354745A4D295162773)
Storage Array Type: VMW_SATP_DEFAULT_AA
Storage Array Type Device Config: SATP VMW_SATP_DEFAULT_AA does not support device configuration.
Path Selection Policy: VMW_PSP_RR
Path Selection Policy Device Config: {policy=iops,iops=1,bytes=10485760,useANO=0;lastPathIndex=2: NumIOsPending=0,numBytesPending=0}
Path Selection Policy Device Custom Config:
Working Paths: vmhba33:C0:T3:L4, vmhba33:C1:T3:L4, vmhba33:C2:T3:L4, vmhba33:C3:T3:L4