Hi People,
Can anyone here please share some script to find the VMFS datastore that is thin-provisioned and its empty space that can be reclaimed ?
Thanks,
You can check the Tin Provisioning status with esxcli like this:
$esxcli = Get-VMHost myesxi | Get-EsxCli
$esxcli.storage.core.device.list() | Select Device, ThinProvisioningStatus, Model, DisplayName | Format-Table -AutoSize
Device ThinProvisioningStatus Model DisplayName
------ ---------------------- ----- -----------
naa.600508b1002c1cc6ba7bae4203e7faae unknown LOGICAL VOLUME HP Serial Attached SCSI Disk (naa.600508b1002c1cc6ba7bae4203e7faae)
mpx.vmhba32:C0:T0:L0 unknown Internal SD-CARD Local USB Direct-Access (mpx.vmhba32:C0:T0:L0)
naa.6000eb38ccef45630000000000000189 unknown iSCSIDisk LEFTHAND iSCSI Disk (naa.6000eb38ccef45630000000000000189)
naa.6000eb38ccef45630000000000000153 unknown iSCSIDisk LEFTHAND iSCSI Disk (naa.6000eb38ccef45630000000000000153)
A ThinProvisioningStatus value of unknown indicates that LUN is not thin-provisioned. Otherwise it would display as yes.
You can filter for these only with:
$esxcli.storage.core.device.list() | Select Device, ThinProvisioningStatus, Model, DisplayName | Where {$_.ThinProvisioningStatus -eq 'yes'}
Also see: Identify Thin-Provisioned Storage Devices
Hi MKguy thanks for the reply. Is there any way to get the capacity and the VMFS datastore name / label as well on those data store ?
Sure is, try something like this:
$h = Get-VMHost myesxihost.local $esxcli = $h | Get-EsxCli New-VIProperty -ObjectType Datastore -Name LunId -Value { $args[0] | Get-ScsiLun | Select -Expand CanonicalName | Group-Object | Select -Expand Name} $h | Get-Datastore | Where {$_.Type -eq 'VMFS'} | Select Name, LunId, CapacityGB, FreeSpaceGB, FileSystemVersion, @{ N='ThinProvisioningStatus'; E={ $esxcli.storage.core.device.list($_.LunId) | Select -Expand ThinProvisioningStatus } } | FT -Autosize
This should produce output like this:
Name | LunId | CapacityGB | FreeSpaceGB | FileSystemVersion | ThinProvisioningStatus |
---- | ----- | ---------- | ----------- | ----------------- | ---------------------- |
SAN_Datastore_1 | naa.6000eb38ccef45630000000000000453 | 499,75 | 113,63 | 5.60 | unknown |
SAN_Datastore_2 | naa.6000eb38ccef45630000000000000a7c | 2047,75 | 1799,50 | 5.60 | unknown |