Contents

PowerCLI to Reclaim Disk Space in ESXi

You are here:
← All Topics

Steps on how to use PowerCLI to reclaim disk space in ESXi

VMware UNMAP is a command to reclaim space from thin provisioned volumes from storage array.

When data is deleted in thin provisioning VMFS Datastore, the storage array is unaware of that deletion. The storage array still “sees” that data as being allocated until VMFS UNMAP inform the storage array the blocks that it had allocated in use are now able to be unmapped and deleted

Connect to ESXi 6.7 Host with PowerCLI

#Connect to ESXi
$ESXi = "10.100.27.1"
$Username = "root"
$Password = "[email protected]"
Connect-VIServer $ESXi -user $Username -pass $Password

List all Device Name with ESXCLI -v2

$esxcli = Get-EsxCli -VMhost (Get-VMHost) -V2

$esxcli.storage.vmfs.extent.list.Invoke() | Select VolumeName, DeviceName

VolumeName            DeviceName                          
----------            ----------                          
SAN1-Datastore        naa.6000d31000bb3c000000000000000003
SAN2-Datastore        naa.6000d31000bb3c000000000000000004

Verify that SAN1-Datastore & SAN2-Datastore is VAAI Delete (UMAP) supported

 
Foreach ($Extent in $Extents) {
    $esxcli.storage.core.device.vaai.status.get.Invoke() | ? Device -eq $Extent.DeviceName | Select Device, DeleteStatus }
    

Device                               DeleteStatus
------                               ------------
naa.6000d31000bb3c000000000000000003 supported   
naa.6000d31000bb3c000000000000000004 supported   


PowerCLI to Reclaim Disk Space in ESXi

$Agr = @{
    volumelabel = "SAN1-Datastore"
}
$esxcli.storage.vmfs.unmap.Invoke($Agr)

or login ESXi host via SSH, and run the following commands

esxcli storage vmfs unmap -l SAN1-Datastore

Monitor the progress of reclaim

Login to ESXi via SSH, and check the /var/log/hostd.log for Unmap: Async Unmapped 200 blocks from volume 56791c92-2dd6912d-4683-44a84228b775

tail -f 10  /var/log/hostd.log

Unmap: Async Unmapped 200 blocks from volume 56791c92-2dd6912d-4683-44a84228b775

Enter esxtop and press u to go to Disk View (LUN Mode).

Select A, O & P

Current Field order: AbcdefghijklmnOP

* A:  DEVICE = Device Name
  B:  ID = Path/World/Partition Id
  C:  NUM = Num of Objects
  D:  SHARES = Shares
  E:  BLKSZ = Block Size (bytes)
  F:  QSTATS = Queue Stats
  G:  IOSTATS = I/O Stats
  H:  RESVSTATS = Reserve Stats
  I:  LATSTATS/cmd = Overall Latency Stats (ms)
  J:  LATSTATS/rd = Read Latency Stats (ms)
  K:  LATSTATS/wr = Write Latency Stats (ms)
  L:  ERRSTATS/s = Error Stats
  M:  PAESTATS/s = PAE Stats
  N:  SPLTSTATS/s = SPLIT Stats
* O:  VAAISTATS= VAAI Stats
* P:  VAAILATSTATS/cmd = VAAI Latency Stats (ms)

Use a-p to change order.
Uppercase moves a field left, lowercase moves a field right.
Use any other key to return:

Check the following counter

  • Delete – The number of successful DELETE commands
  • Delete_F – The number of DELETE commands failed
  • MBDEL/s – The rate at which the DELETE command getting processed

PowerCLI to Reclaim Disk Space in ESXi

Click Refresh to verify the used size of LUN in Dell Compellent is reducing slowly

PowerCLI to Reclaim Disk Space in ESXi

It will take quite sometime for the Reclaim process to be completed

Verify that the free space is increased from Dell Compellent once the Reclaim process is completed

Top Posts & Pages

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top