Storage vMotion to thin disk does not reclaim null blocks
search cancel

Storage vMotion to thin disk does not reclaim null blocks

book

Article ID: 321532

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

Symptoms:
  • When using Storage vMotion to move a thin disk between two VMFS volumes with the same block size, null blocks are not reclaimed.
  • Null blocks are copied from source to destination resulting in a VMDK that is the same size, despite thin being chosen as the destination disk type.
  • When attempting to thin a disk after either using VMware Tools Prepare to shrink option or using a third-party product to zero disk blocks within a guest operating system, null blocks are copied.


Environment

VMware vSphere ESXi 5.5
VMware vSphere ESXi 5.0
VMware vCenter Server 6.0.x
VMware ESX 4.1.x
VMware vCenter Server 5.1.x
VMware vSphere 7.0.x
VMware vCenter Server 4.0.x
VMware vSphere ESXi 5.1
VMware vSphere ESXi 6.0
VMware vCenter Server 5.0.x
VMware ESXi 4.1.x Embedded
VMware vCenter Server 4.1.x
VMware ESX 4.0.x
VMware ESXi 4.0.x Embedded
VMware vSphere 6.x
VMware ESXi 4.1.x Installable
VMware vCenter Server 5.5.x
VMware ESXi 4.0.x Installable

Cause

This issue occurs when the destination datastore is of the same block size as the source datastore, regardless of whether the datastores are VMFS3 or VMFS5.

When the source filesystem uses a different blocksize from the destination filesystem, the legacy datamover (FSDM) is used. When the blocksizes of source and destination are equal, the new datamover (FS3DM) is used. FS3DM uses VAAI or just the software component. In either case, null blocks are not reclaimed.

 

Resolution

This is an expected behavior.

To work around this issue, Storage vMotion the virtual machine or VMDK to a datastore that has a different block size. This reclaims the zeroed out disk space.

To shrink a thin provisioned disk (VMDK):
  1. Use a third-party tool within the guest operating system to zero-out disk blocks that may have previously been written with data, but have subsequently been deleted.
  2. Storage vMotion the virtual machine or VMDK to a datastore formatted with a different block size.
For example, if the VMDK is on a datastore formatted with 2 MB blocks, format the target VMFS datastore with a 1 MB, 4 MB, or 8 MB block size.

To reclaim the unused space of a virtual disk in ESXi/ESX 4.1 or later:
 
Note: Where vmkfstools supports the -K option (--punchzero), you can reclaim the zeroed blocks of thin-provisioned virtual disks without the need to clone to another VMFS datastore with a different block size.
  1. Ensure that the disk has no Snapshots.
  2. In a Windows virtual machine, run the SDelete command (or a tool with similar functionality) to zero out all unused space. The syntax for the SDelete command is SDelete -z driveletter. If you use SDelete, ensure that you use version 1.6 or later.

    Note: Zeroing all unused blocks inflates the disk to its full size as if it was an eagerzeroed disk. Ensure that there is sufficient space on the datastore to allow the disk to grow to its full size. For more information, see Determining if a VMDK is zeroedthick or eagerzeroedthick (1011170).
     
  3. Shut down the virtual machine or temporarily remove the virtual disk from the virtual machine to ensure that it is not in use.
  4. Erase all unused blocks by running the command:

    vmkfstools -K /path/to/disk-name.vmdk


    Note: The punchzero (vmkfstools -K) command is not compatible with NFS datastores. This command is also not supported for thick provisioned disks on VMFS6

    This option de-allocates all zeroed out blocks and leaves only those blocks that were allocated previously and contain valid data. The resulting virtual disk is in thin format. For more information on the vmkfstools command, see Removing Zeroed Blocks in the ESX Configuration Guide.


Additional Information