Vmkfstools: Difference between revisions

Line 112: Line 112:


Reclaim disk space by returning unused blocks of data in the virtual disk to the host OS.  
Reclaim disk space by returning unused blocks of data in the virtual disk to the host OS.  
Note that this will only work if your virtual disk is of type thin.
Note that this will only work if your virtual disk is of type thin.
You will also need to zero out the unused blocks of data in the guest OS.
 
Before running it you will also need to zero out the unused blocks of data in the guest OS.


For a windows VM, you can use Microsoft's tool [http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx sdelete].
For a windows VM, you can use Microsoft's tool [http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx sdelete].
Line 123: Line 125:
  cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
  cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
to zero out the unused space.  
to zero out the unused space.  
Note of warning that you should stop database -and other disk intensive- services before running the above.
Note of warning that you should stop database -and other disk intensive- services before running the above.


Line 142: Line 145:
  0      disk.vmdk
  0      disk.vmdk


You can also use the vSphere Client data browser to see the effect of reclaiming disk space
You can also use the vSphere Client data browser to see the effect of reclaiming disk space.
 
If you try to run this command against a VM living on NFS storage you might end up seeing the following error:
vmkfstools --punchzero myvmdk.vmdk
Not a supported filesystem type
 
The error is a bit confusing as you might expect vmkfstools to talk about the guest OS here, but it is actually reporting that NFS does not support the punchzero option.
 
Your solution is to either move the vmdk by hand to storage not located on VMFS or use storage vmotion to migrate to non NFS storage. On moving using storage vmotion, the zero data is already being discarded. So you can just storage vmotion back afterwards and you have reclaimed the lost disk space.


=== Links ===
=== Links ===
1,274

edits