Introduction
This document describes options on how to reclaim space within a thin-provisioned virtual machine (VM) that resides on HyperFlex.
Requirements
There are no specific requirements for this document
Components Used
The examples in this document were validated on VMware vSphere Hypervisor (ESXi) 6.5.
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, ensure that you understand the potential impact of any command.
Problem:
HyperFlex does not have a mechanism to reclaim space within a thin provision VM that is freed up. Thin provisioning allows for the on-demand growth of a virtual disk. This allows for more efficient use of space from the storage system compared to thick provision. When files on a thin-provisioned virtual drive are deleted, the disk size is not automatically reduced. The reason for this is that the operating system only deletes the indexes from the file system table. This results in the appearance of the quick deletion of files, but no reclamation of space.
Solution:
Reclaim Space Within A Microsoft Windows VM On A HyperFlex Cluster
This section provides some options on how to reclaim space on thinly provisioned virtual drives. These tools zero the blocks of data you deleted. Before you perform any operation that zeros out blocks, ensure you have backups. Also, make sure there are no previous snapshots on the VM that you complete the steps on. This includes SENTINEL snapshots. Removal of the SENTINEL snapshot stuns the VM for a prolonged period of time. You can choose to power down the VM before you remove all snapshots in order to not stun the VM.
Additional information on VMware and Snapshot management is contained in these articles:
A snapshot removal can stop a virtual machine for a long time
Best practices to use snapshots in the vSphere environment
Reclaim Space on Thinly Provisioned Disks on Microsoft Windows VMs
SDelete, is a free utility from Microsoft Sysinternals Suite, that is used to reclaim space.
Caution: SDelete -z causes the virtual machine operating system to use up 100% of the available space disk while free space is zeroed. This leads to a temporary increase in used space on the datastore.
If you hit the ENOSPC condition or have a Hyperflex cluster in read-only mode please be aware of this since there is a possibility it is counterproductive. That is if one or multiple VMDKs usage increased up to 100% (as a consequence of SDelete) represents a considerable increment of the Hyperflex overall cluster storage capacity used then it must be used with caution
This screenshot shows the VM VMDK side before you run SDelete:
Once you download SDelete to the target VM, unzip the file.
Enter cmd to open the Command Prompt application. Right-click and choose Run as administrator.
Navigate to the directory where you uncompressed SDelete.
Enter the sdelete.exe -z <drive letter>: command and click Agree.
This screenshot shows the VM VMDK size after the SDelete operation:
Reclaim Space Within A Linux VM On A HyperFlex Cluster
You can use the dd utility to zero out the areas where the deleted data resides. Enter df -h in order to check the free space on the Linux OS.
Enter the dd bs=1M count=90112 if=/dev/zero of=zero command in order to zero out the empty space.
This command zeros out 90GB of space. Modify this command to fit your use case.
Command input breakdown:
bs is the block size used
count is the number of blocks
if is the input file
of is the output file
After this completes, the VMDK file grows.
This screenshot shows the size of VMDK in vCenter:
In order to reclaim the space, enter the rm zero command:
/$ sudo rm zero
[sudo] password for user: <---Enter password for user
The VM VMDK size in vCenter after the deletion of the zero files is shown in this screenshot.
Related Information