A few weeks, my good pal Cody Hosterman over at Pure Storage was experimenting with VAAI and discovered that he could successfully UNMAP blocks (reclaim) directly from a Guest OS in vSphere 6.0. VAAI are the vSphere APIs for Array Integration. Cody wrote about his findings here. Effectively, if you have deleted files within a Guest OS, and your VM is thinly provisioned, you can tell the array through this VAAI primitive that you are no longer using these blocks. This allows the array to reclaim them for other uses. I know a lot of you have been waiting for this functionality for some time. However Cody had a bunch of questions and reached out to me to see if I could provide some answers. After conversing with a number of engineers and product managers here at VMware, here are some of the answers to the questions that Cody asked.
Q. Does VMware support UNMAPs directly from the Guest OS in vSphere 6.0.
Yes. The issuing UNMAPs directly from the Guest OS to reclaim space is supported in vSphere 6.0.
Q. What are the prerequisites required for UNMAP to run?
There are a number of prerequisites which must be met. These are:
- VMDK must be thin provisioned
- Virtual Machine Hardware version must be 11 (ESXi 6.0)
- The advanced setting EnableBlockDelete must be set to 1
- The Guest OS must be able to identify the disk as thin (Windows 2012 [updated 30-Oct-2015] uses the B2 mode page to achieve this)
Q. Does reclaiming only work for UNMAP? What about TRIM?
This is an “it depends” answer. TRIM is only used when the underlying device is an SSD – Solid State Disk. From what I understand, the TRIM gets converted to UNMAP in the I/O stack. However, there are some issues with TRIM getting converted into UNMAP. UNMAP work at certain block boundaries on VMFS, whereas TRIM do not have such restrictions. So, certain TRIMs converted into UNMAPs may fail due to block alignment issues.
Q. Is this based on a VMware fling?
No. This is a feature of the Virtual Machine HW version 11, and functionality found in the Guest OS.
Q. Which Guest OS support UNMAP?
Currently, the only Guest OS which support this are Windows 2012 [Updated 30-Oct-2015]. Linux distributions check the SCSI version, and unless it is version 5 or greater, it does not send UNMAPs. We currently support only SCSI-2. There are further details in KB article 2112333.
Q. How do you trigger UNMAP from the Guest OS?
The point here is that UNMAP is triggered from the Guest OS, not from some VMware provided tool. Our understanding is that UNMAP is triggered by operations such as a defrag of the filesystem or a file deletion. Cody also mentioned in his blog post that an operation called “optimize drive” also seemed to work for him. This is a Microsoft tool, and we don’t have much insight into how it works, but one suspects that it behaves in a similar fashion to defrag.
Q. When might in-guest UNMAP not work?
- If the advanced option is not set on ESXi
- If the underlying disk is not thin
- Virtual Hardware versions is not v11 or higher
- If the Guest OS cannot identify the disk as thin, e.g. it does not support the B2 mode page (Windows 2012 [updated 30-Oct-2015])
- If the Guest OS is Linux
- If the registry key for UNMAP support is disabled
I know a lot of you have been asking for this functionality for some time. Enjoy!