Reclaim Disk Space From Thin Provisioned VMDK F..
Reclaim Disk Space From Thin Provisioned VMDK F..
Log in to create and rate content, and to follow, bookmark, and share content with other members.
Like 0 Comment 0
When you have some VMs with thin provisioned disks, you may have noticed that these will continue to
grow, and never shrink, even after cleaning out data from within the VM. Currently, VMware does not have
automatic space reclamation. Luckily, there are some tools to allow you to reclaim unused space from your
virtual thin disks. The only downside is that you have to power off the affected machines.
Here we see that the device is indeed Thin Provisioned and supports VAAI. Now we can run a command to display the VAAI
primitives supported by the array for that device. In particular we are interested in knowing whether the array supports the
UNMAP primitive for dead space reclamation (what we refer to as the Delete Status). Another esxcli command is used for
this step 'esxcli storage core device vaai status get -d <naa>':
a. naa.60a98000572d54724a346a6170627a52
VAAI Plugin Name: VMW_VAAIP_HDS
ATS Status: supported
Clone Status: supported
Zero Status: supported
Delete Status: supported
The device displays Delete Status as supported meaning that it is capable of sending SCSI UNMAP commands to the array
when a space reclaim operation is requested.
Reclaiming disk space only works when the blocks on your virtual disk are really empty. Deleting data usually
only removes the entries from the file allocation table but does not zero the blocks. As a result, ESX will still
think the blocks are in-use. There are a few tools available to do this on Windows- and Linux-hosts.
Windows
Download SDelete . This command-line tool has a powerful feature which can track and zero unused blocks.
You won't notice a difference in used disk space from within your VM, but this will enable VMware to track
unused blocks and release them back to your datastore, effectively shrinking your thin provisioned disk.
sdelete.exe -z [drive:]
Replace [drive:] with the affected disk or partition. Note that when you have multiple partitions on a single
virtual disk, you need to do this on all partitions for it to be effective. Otherwise, reclamation will only be partial
because not every data block will be zeroed.
Linux
Linux has a different approach. Depending on your filesystem, there are several tools out there, but one that
works everytime is by filling free space with a file of zeroes.
First, be sure to shutdown all services which write to the volume you want to shrink as to avoid problems with
them running out of free disk space. Next, use dd to completely fill free space with zeroes:
Replace [mounted-volume] with wherever you've mounted the volume. Note that when you have multiple
partitions on a single virtual disk, you need to do this on all partitions for it to be effective. Otherwise,
reclamation will only be partial because not every data block will be zeroed.
When data has been deleted, you're ready to really reclaim disk space. This is done by "punching out" zeroed
blocks in the virtual disk's VMDK file.
First, power off the affected VMs and log into any ESX server with access to the VMFS datastore which has the
VMDKs to shrink. Cd to the datastore and volume. Next, launch vmkfstools:
vmkfstools -K [disk].vmdk
Replace [disk] with the disk name. For ESX, don't reference the flat VMDK (usually called disk-flat.vmdk).
You have to reference the descriptor file (disk.vmdk).
Depending on the size of the disk, this can be a lengthy process. When finished, all blocks that were previously
zeroed from within the VM will now be gone from the VMDK and space will have been reclaimed.
Note:
1. VMware Horizon View users: Reclamation of disk space won't apply to VDs until your next recompose.
2. This above procedure only works with thin provisioned virtual disks
ATTACHMENTS
Visibility: Open to anyone 13388 Views
0 Comments
Related Content
Latest VMware vSphere over NFS (file) best practices document from HDS
Recommended Content
QUICK LINKS