Storage thin provisioning can save space on a VMware Virtual Machine Disk File (VMDK), but reclaiming that space...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
requires the use of tools described below.
I have experimented with Virtual Machine Disk Format (VMDK) thin provisioning since the beta release of vSphere 4.0 as I don't have much storage space to spare.
Before we get into the nuts and bolts of what I discovered, here's some background on thin provisioning. Normally, when a 50 GB VMDK is created, it immediately eats up 50 GB of disk space on the Virtual Machine File System (VMFS) volume. Since application owners often demand more space than they truly need, there is a lot of expensive storage area network (SAN) disk capacity dedicated to these applications that will never be used. When you thin-provision a VMDK, storage is not allocated to the VMDK unless it is actually used. As long as only 10 GB of the allocated 50 GB disk is used, only 10 GB is claimed.
Once the disk gets filled with data, the 50 GB that was claimed is used, which is very logical. But it is not possible to delete the data and reclaim this deleted space at storage level. Once a thin-provisioned disk grows, it won't shrink. This is not because of limitations on storage or vSphere level but because storage and vSphere don't receive the information that those blocks are empty. Windows does not delete a file when you delete it; it just updates the master file table and registers that block X to Y is now again available for writing, but the space isn't emptied. This is why neither vSphere nor storage knows that the block can be reclaimed.
Some storage vendors, however, have worked on special drivers that can interact with the guest operating system and tell the storage that it can reclaim some blocks when the guest deletes files.
Storage VMotion to reclaim space
When I first heard about thin provisioning at VMworld 2009 in Cannes, I immediately thought about how I would get to my customers' existing installed base without downtime. Luckily, in the vCenter Migration wizard, there is a question to change the data store for a VMDK or all of the VMDKs of a virtual machine (VM) and immediately change the disk type from thick- to thin-provisioned. You can use the Storage VMotion feature on a VMDK and reclaim the unused space in this way, but remember that only empty space that has not previously been written to by the guest OS can be reclaimed.
As a test, I tried the following:
- Added a 10 GB thin-provisioned VMDK to a Windows 2003 virtual machine.
- Filled the VMDK with data and later deleted this data.
- In vCenter, saw that the disk now used 10 GB. As expected, no data had been freed on storage level by deleting it inside Windows.
- Used Storage VMotion to migrate this VMDK to a different data store. This did not free up space on storage level however. It didn't matter if in the wizard I selected Keep Disk Format or "Change to Thin Provisioned Disk."
This proved that deleting files does not reclaim unused blocks. But it is still quite a waste that these blocks can't be reclaimed again, so I looked into other ways to reclaim this space.
Using sdelete to reclaim space
The tool I used next is from Sysinternals called sdelete. To reclaim space on a Windows VMDK, download sdelete to the local hard disk. In my example, I used sdelete to clean the E: drive of the VM. Running sdelete with the following command will clear all lost space: "sdelete - c E:". Since this is a rather heavy I/O operation, you should plan this action very carefully in a production environment. Also note that after clearing, the blocks will really be empty. If a file is deleted by accident, it is almost impossible to use data recovery tools on that disk. So have good backups available before experimenting with this.
After sdelete has cleared your drive, vCenter will still show maximum disk usage, so the last step in reclaiming space is to use Storage VMotion. Since the disk is already in thin-provision format, you can choose the wizard to "Keep Disk Format" or "Change to Thin Provisioned Disk." Both options will now really free unused space. After the Storage VMotion has finished, you might have to press "Update storage usage" to force vCenter to recalculate storage usage, but after that, the VM will use far less storage then previously.
Using the VMtools shrink option
In a Windows VM with VMware Tools running, you can right-click the VMtools icon and select Open VMware Tools. One of the tabs displayed will be "Shrink." Normally, this would clear all unused disk space, but strangely this doesn't work for thin-provisioned disk. So unfortunately, this option isn't helpful when you want to reclaim unused disk space.
|Gabrie van Zanten (VCP) has been in the IT industry for 12 years. Currently he is a virtualization architect for a worldwide consultancy company and has designed and maintained virtual infrastructures for a number of customers. He has written articles for magazines and frequently publishes in-depth articles at his weblog, GabesVirtualWorld.|