Month: Aug 2016
How to cancel a hang task in vCenter or ESXi host?
Sometime we may need to cancel an hung task like active vmotion/backup which may show as disabled from the vSphere client.
- First check if there is an active task running for the VM in the Task and Events Tab.
- Log in to ESXi host via SSH (using e.g. putty). If the SSH service is not running on ESXi host, please enable it.
- Run ps command. use grep e.g. ps | grep VM_name
- Kill the parent process by running the command kill id_parent e.g. kill 859467
- The hang task should be canceled now and will reflect in the Tasks and Events in the vCenter.
A QUICK REFERENCE OF VSPHERE IDS
Here is a list of a number of the different IDs used in the virtual infrastructure and how they are used:
- VC Instance UUID(aka serverGuid): This is a GUID that identifies the vCenter server. This is accessible from the AboutInfo property in the VIM API. The property name is AboutInfo#instanceUuid. It’s set at install time and is persisted so the value is durable for a given VC instance.
To access this via PowerCLI you can use the following:
| 1
2 3
|
PS C:\> $vcenter = Connect-viserver vcsa-01a.corp.local -User Administrator@vsphere.local -Password VMware1!
PS C:\> $vcenter.InstanceUuid d322b019-58d4-4d6f-9f8b-d28695a716c0 |
- The ESX Host UUIDis read by the ESX host from the System Management BIOS (SMBIOS). This UUID is not generated by VMware, it is unique to the hardware and is set in the BIOS by the vendor.
To access this via PowerCLI you can use the following:
| 1 | (Get-VMHost | Select -first 1).ExtensionData.hardware.systeminfo.uuid |
- VC-VM Instance UUID: This is the vc.uuid property in the VM vmx configuration file and also the instanceUuid property on the VmConfigInfo for a VirtualMachine in the VIM API. This UUID is used by vCenter to uniquely identify VMs that it is managed. vCenter assigns this UUID to the VM after it is created. There are different workflows where a VM may not have a UUID initially or may have a duplicate. vCenter actively looks over the VM inventory and will automatically patch the VM instance UUID if it sees a duplicate.
The scope of this uniqueness scan is a vCenter instance. If there are duplicate VC-VM Instance UUIDs, they will not be detected as duplicates unless the VMs are managed by the same vCenter instance. This value can be changed through the API.
To access this via PowerCLI you can use the following:
| 1
2 3 |
PS C:\> (Get-VM | Select -first 1).extensiondata.config.InstanceUUID
502e363d-393c-b0a4-8ede-639db30a625e |
- VM SMBIOS UUID: This is the uuid.bios property in the VM vmx configuration file. In the VIM API, this is the uuid property on the VmConfigInfo for a VirtualMachine managed object. This UUID is visible to the guest OS as the SMBIOS UUID. VMware generally try to avoid changing this UUID since it is often used by applications that manage the guest OS instances. When the VM is migrated this UUID is maintained.
vCenter does a best effort to try to make sure these UUIDs are unique in an environment. For operations like clone and deploy that create a new VM, a new UUID is provided to the VM by clearing the uuid.bios from the VM’s vmx file. If the VM is copied without vCenter’s knowledge, 3rd party tools are advised to do the same thing as vCenter. A new uuid.bios is generated the next time the VM is powered on. This UUID is generated by the ESXi server so vCenter does not have to be in the control flow for the uuid.bios to be generated.
To access this via PowerCLI you can use the following:
| 1
2 3 |
PS C:\> (Get-VM | Select -first 1).extensiondata.Config.UUID422ee9f4-6cfd-1fb7-1376-a8ecb8eb8568 |
- VM Location ID: This identifier is stored in the VM configuration file as the variable uuid.location. In the VIM API, the name is locationId also on the VmConfigInfo of the VirtualMachine. This is one other detail that might be relevant to a 3rd party solution that might be moving the VM without vCenter’s knowledge. This property is used in conjunction with the VM SMBIOS UUID. This property is a hash of the VM’s configuration file and some UUID of the ESXi. The purpose of this UUID is to detect out-of-band migrations and copies of the VM. If vSphere (or Workstation/Fusion) detect that the locationId is no longer valid, it will pop up dialog/question/error asking the user why the locationId is no longer valid. The user is prompted to answer whether the VM was moved or copied. The purpose is so that vSphere can determine whether it should keep the existing the SMBIOS UUID or generate a new one.
Recall, I mentioned that vCenter is doing a best effort to ensure the SMBIOS UUID is unique. But when it detects a potential conflict, vCenter will not automatically patch the UUID since this could break 3rd party and VMware products that rely on the guest visible UUID to correlate the VM with other management entities in the environment.
The way 3rd party solutions can best interoperate with vCenter and it’s attempt to preserve a unique SMBIOS UUID is to be aware of these semantics. If a 3rd party solution or program is moving the VM, it should clear out the uuid.location (ie. ConfigInfo.locationId) property. On next power on, a new uuid.location will be generated, binding the VM to ESXi host and the file path where it is running.
Despite this however, there is a theoretical and real possibility that there could be duplicate SMBIOS UUIDs. Because vCenter is deferring to what the user of the system what the the SMBIOS UUID should be, it will not change the UUID automatically if it detects conflicts. If there SMBIOS UUIDs that are duplicated, it will not fix them.
To access this via PowerCLI you can use the following:
| 1
2 3 |
PS C:\> (Get-VM | Select -first 1).extensiondata.config.LocationId
564d043c-5dab-5413-c4a7-fb0837d354d9 |
- VM MoRef: The VM MoRef is a short key used by a vCenter instance to identify the VM. This is the primary identifier used by the VIM API to refer to the VM. The other identifiers can generally be used to find the VM, but the VM MoRef is the one that must ultimately be used to get data and issue operations to modify the VM.
In general, the MoRef is the important identifier because that’s what is used in the VC database to associate a VM to its stats, events, and configuration.
In environments where multiple vCenters are used, the MoRef will not necessarily be unique. As a result, another identifier needs to paired with the VM MoRef or used instead. In general, vSphere uses a combination of the vCenter instance UUID (ie. the serverGuid) with the MoRef to identify the VM for cross-vCenter scenarios like Linked Mode.
To access this via PowerCLI you can use the following:
| 1
2 |
PS C:\> (Get-VM | Select -first 1).ExtensionData.Moref.Value
vm-43 |
Recommended antivirus exclusions for Hyper-V hosts
If antivirus software is installed and running on a Hyper-V host, there are several exclusions and options that you should configure for optimal operation of Hyper-V and the running virtual machines.
Configure the real-time scanning component within your antivirus software to exclude the following directories, files, and processes:
- All directories that contain VHD, VHDX, AVHD, AVHDX, VSV, and ISO files
- The following default virtual machine configuration directory, if it’s used, and any of its subdirectories:
C:\ProgramData\Microsoft\Windows\Hyper-V
- The following default virtual machine virtual hard disk files directory, if it’s used, and any of its subdirectories:
C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks
- The following default snapshot files directory, if it’s used, and any of its subdirectories:
C:\ProgramData\Microsoft\Windows\Hyper-V\Snapshots
- The following default Cluster Shared Volumes path, if you’re using Cluster Shared Volumes, and any of its subdirectories:
C:\ClusterStorage
- Any custom virtual machine configuration directories, if applicable
- Any custom virtual hard disk drive directories, if applicable
- Any custom replication data directories, if you’re using Hyper-V Replica
- If antivirus software is running on your file servers, any Server Message Block protocol 3.0 (SMB 3.0) file shares on which you store virtual machine files
- Vmms.exe
Note This file may have to be configured as a process exclusion within the antivirus software.
- Vmwp.exe
Note This file may have to be configured as a process exclusion within the antivirus software.
Script to find UUID of RDM Luns in Hyper-V
Run the below command in the Powershell to get the ouput in the text format.
get-cluster ‘custername’ | Get-VM | Get-HardDisk -DiskType “RawPhysical”,”RawVirtual” | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName | fl | Out-File –FilePath C:\temp\RDM-list.txt