VMware

Shrink You damn disk!!!

I have bunch of VMs that need to have their VMDKs shrinked. I think I did all I could think of (and googled).

Example: I have Kali on thick 101 GB disk. I need to shrink it to 25 GB. How can this be done?

PS: No vCenter…



View Reddit by ntnlabsView Source

 

To see the full content, share this page by clicking one of the buttons below

Related Articles

4 Comments

  1. * Browse to the VM Guest file location

    cd /vmfs/volumes/mydatastore/vmname/
    * Clone original disk to a thin copy

    vmkfstools -i <SERVERNAME>.vmdk -d thin thin-<SERVERNAME>.vmdk
    * Rename the original disk

    vmkfstools -E <SERVERNAME>.vmdk orig-<SERVERNAME>.vmdk
    * Rename the thin disk to the original disk name

    vmkfstools -E thin-<SERVERNAME>.vmdk <SERVERNAME>.vmdk
    * Verify that the VM Guest boots and runs correctly
    * Remove original Thick disk/s

    vmkfstools -U orig-<SERVERNAME>.vmdk

    [Source](https://www.bonusbits.com/wiki/HowTo:Convert_a_VMDK_from_Thick_to_Thin_on_ESX)

  2. The usual tools will work if you do it right.

    http://buildvirtual.net/reclaim-used-space-with-vmkfstools-punchzero/ for instance works. Shut down the VM, run punchzero, wait. Obviously no snapshots have to exist.

    To change the type of disk https://kb.vmware.com/s/article/2014832

    Also, https://kb.vmware.com/s/article/1028042

    If you don’t reload the vmx manually, you have to remove the machine from inventory (NOT from disk, from inventory) and then re-add it to inventory by going to the datastore browser and clicking “add to inventory” on the VMX. This step is necessary with vCenter, not sure if it’s necessary on ESXi, maybe not.

    https://kb.vmware.com/s/article/1026043

    If doesn’t work, there is some user error.

Leave a Reply