esxcli command help

List mounted datastores:

esxcli storage filesystem lists

Shutdown or Reboot the ESXi Host:

esxcli system shutdown <poweroff|reboot> --delay 10 --reason "Just Poweroff"

 

Advertisements

vSphere Snapshot Basics – Part 2

More about Snapshots

Snapshots are not backups, but backup software will leverage snapshots to take backups of the VM.

  • When you take snapshots the delta disks can potentially grow to the size of the original disk
  • When you take snapshots be careful because you can easily run out of storage space on the datastore

Snapshot Best Practices

If you plan to take snapshots

  • Do not over commit the datastore capacity
  • In fact you should be under commit by up to 30%
  • Do not create more than 1 snapshot
  • Do not keep snapshots for more that 1 day, in exceptional cases on production VMs (powered VMs) you may keep it up to 2 days

Difference between Clone and Snapshot

Clone is another copy of the virtual machine, where as a snapshot is a capture of point time state of the virtual machine. If you delete the virtual machine, the snapshot will also be deleted along with the it, however the clone will remain intact because its a separate copy.

vSphere Snapshot Basics – Part 1

What is a Snapshot?

  • It is a point in time state of the virtual machine
  • When you take a snapshot a delta disk gets created.
  • If you create another snasphot another delta disk will be created
  • The delta disk is mounted as ReadWrite (RW) whereas the original disk is mounted as ReadOnly (RO)
  • This delta disk is thin priovisioned disk, and grows in chunks of 16MB
  • After creation of Snapshot all disk writes within the VM go to the Snapshot-disk (delta disk) and not to the original disk (flat disk)

In vSphere, snapshots are based on “COW“

COW ==> Copy on Write Snapshots

In COW, all new writes always go to the delta disk.

LUN Runtime Name

Quote

Most vSphere Administrators need to inspect the LUN runtime names discovered by the ESXi hosts. What usually gets overlooked is that runtimes name across different hosts could be different. Hence I like to look at all the runtime names discovered across all hosts for that ‘said’ LUN. Here is an oneliner which does the same, pass the CanonicalName (NaaID) and it will tell you the RuntimeName:

function Get-DatastoreRuntimeName() {
    param (
        [string]$CanonicalName = $(Read-Host -prompt "Enter a CanonicalName")
        )

    Get-VMHost `
        | Get-VMHostStorage `
        | Select-Object -ExpandProperty ScsiLun `
        | ?{$_.LunType -like "disk"} `
        | Select-Object VMHost,CanonicalName,RuntimeName,@{Name="CapacityGB";Expression={[int]$_.CapacityGB}} `
        | ?{$_.CanonicalName -like $CanonicalName}
}

What I usually do is find the NaaID for a Datastore and then use the NaaID to query the RuntimeName. Yes that’s a 2 step process. There might be an better way, but haven’t tried to explore it, since this gets my job done. 😉

vSphere Datastore Report

I needed to generate a Datastore report. All the information I was interested in was available in via the Get-Datastore cmdlet, however it was nested deep. Hence churned up a quicky PowerCLI oneliner:

Get-Datastore `
    | Select-Object -ExpandProperty ExtensionData `
    | Select-Object `
        @{Name="Name"; Expression={$_.Name}},`
        @{Name="CanonicalName"; Expression={$_.Info.Vmfs.Extent.DiskName}},`
        @{Name="CapacityGB"; Expression={[int]($_.Summary.Capacity/1GB)}},`
        @{Name="FreeGB"; Expression={[int]($_.Summary.FreeSpace/1GB)}},`
        @{Name="ProvisionedGB";Expression={[int](($_.Summary.Capacity - $_.Summary.FreeSpace + $_.Summary.Uncommitted)/1GB)}},`
        @{Name="Moref"; Expression={$_.MoRef}} `
    | ft

In case you are interested in the details of a specific datastore, you can filter the output from the previous oneliner, using the Where-Object cmdlet.

Check VMHost VAAI Status

I needed a quick way to generate a report about VAAI status for all hosts in the vCenter Server. Hence wrote a PowerCLI oneliner to get the job done:

Get-VMHost  | %{ 
  Get-AdvancedSetting -Name DataMover.HardwareAcceleratedMove -Entity $_
  Get-AdvancedSetting -Name DataMover.HardwareAcceleratedInit -Entity $_
  Get-AdvancedSetting -Name VMFS3.HardwareAcceleratedLocking  -Entity $_
} | Select-Object `
        @{Name="Name"; Expression={$_.Entity}},`
        @{Name="PropertyName"; Expression={$_.Name}},`
        @{Name="Status"; Expression={ if($_.Value){"Enabled"} else{"Disabled"}}}

In case you are not aware of what VAAI is read about it here at KB#1021976.

PowerCLI oneliner to generate version, build and bios details

Here’s a quick oneliner to generate a nice report about the version, build and bios details on each host.

Get-VMHost | Select-Object -Property Name,Version,Build,@{Name='BIOS Version';Expression={(($_|Select-Object -ExpandProperty ExtensionData).Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | ?{$_.Name -like "*bios*"}).Name.Split(' ')[4]}}

PS: there are no spaces or new lines in the code.

Enjoy!