VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso

How to find the VMFS datastore that is thin-provisioned ?

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,

Source VMware KB: Using esxcli in vSphere 5.5 and 6.0 to reclaim VMFS deleted blocks on thin-provisioned LU...

/* Please feel free to provide any comments or input you may have. */
3 Replies
MKguy
Virtuoso
Virtuoso

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

-- http://alpacapowered.wordpress.com
AlbertWT
Virtuoso
Virtuoso

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 ?

/* Please feel free to provide any comments or input you may have. */
0 Kudos
MKguy
Virtuoso
Virtuoso

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:

      

NameLunIdCapacityGBFreeSpaceGBFileSystemVersionThinProvisioningStatus
---------------------------------------------------------------------
SAN_Datastore_1naa.6000eb38ccef45630000000000000453499,75113,635.60unknown
SAN_Datastore_2naa.6000eb38ccef45630000000000000a7c2047,751799,505.60unknown
-- http://alpacapowered.wordpress.com
0 Kudos