Resolving Disk Space Discrepancy on Thin-Provisioned Windows Virtual Machines
search cancel

Resolving Disk Space Discrepancy on Thin-Provisioned Windows Virtual Machines

book

Article ID: 450717

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

A discrepancy exists between the storage usage reported by the vSphere UI and the actual usage within a Windows Guest OS. The vSphere summary tab may indicate the datastore is near capacity while the Guest OS reports significant free space.

Symptoms:

  • The vSphere UI reports higher consumed storage space on the VM summary tab than the Windows Guest OS reports.
  • Production datastore report full capacity due to abnormal storage consumption by a specific virtual machine.
  • Files were deleted on a thin-provisioned Windows VM residing on a VMFS datastore, but space is not reclaimed.

 

 

Environment

VMware vSphere ESXi 8.x,9.x

Cause

When files are deleted within the Windows Guest OS, the file system (NTFS) marks the underlying storage blocks as "free" for future use; however, it does not inherently communicate this status change to the underlying ESXi hypervisor. Consequently, the .vmdk file on the datastore does not shrink, as the host is unaware that the blocks are no longer in use. To synchronize the file system state with the hypervisor storage layer, the Guest OS must issue SCSI UNMAP commands.

Resolution

To reclaim unused space, use the native Windows Optimize-Volume PowerShell cmdlet to force the issuance of SCSI UNMAP commands to the ESXi host.

Prerequisites

  • Snapshots: Ensure the virtual machine has no active snapshots. Space reclamation is not supported on VMs with snapshots.
  • Hardware Version: The virtual machine must be running Hardware Version 11 or higher.
  • VMware Tools: Ensure the latest version of VMware Tools is installed and running.
  • Backups: Perform a full backup of the virtual machine before executing storage reclamation tasks.

Steps to Reclaim Space

  1. Log into the Windows Guest OS as an Administrator.
  2. Open PowerShell as an Administrator.
  3. Execute the following command for the specific drive letter (e.g., C: drive) to be reclaimed: Optimize-Volume -DriveLetter C -ReTrim -Verbose Note: The -ReTrim flag forces the operating system to send UNMAP commands to the hypervisor for all unallocated blocks.
  4. Wait for the process to complete. This operation may take significant time depending on disk size. Do not interrupt the process.

Post-Reclamation Behavior

On VMFS-6 datastores, space reclamation is processed asynchronously. The reduction in datastore usage will not be instantaneous; the hypervisor reclaims space at a low priority to maintain system performance.

Additional Information