Categories
HowTo Guides VMWare

Shrinking vmdk disks in VMWare ESXi

I needed to move a VM from the Datastore onto my laptop today, and found that my VM had numerous vmname-001.vmdk / vmname-002.vmdk virtual disks. The size on these disks would mean it taking hours to move the VM from the VM server to my laptop – so I needed to tidy up and shrink if possible.

I first found that deleting any old or redundant snapshots (taken as a safety measure when updating items within my VM!) consolodated all the -001 / -002 / etc .vmkd files into one ‘master’ vmname.vmdk file. But this file was the full size of the allocated disk size – in my example 160Gb, but the VM was infact only using about 40Gb… time to shrink! Via SSH to the console, I ran the following (with the VM shutdown and powered off of course!).

Firstly – get yourself into the VM storage area for your VM :

cd /vmfs/volumes/vmstorename/vmname

Now run the VM Filesystem tools to shrink your .vmdk – this may take a while, in my case from 160Gb down to 36Gb took about 10 mins :

vmkfstools --punchzero vmname.vmdk

36Gb – Much easier to move around.

By Mik Canavan

I'm a tech obsessed and self-confessed geek. As the Technical Director at Fivenines UK, I'm lucky that I get to faf with gadgets, design websites and fix servers...

Leave a Reply

Your email address will not be published. Required fields are marked *