VMware Cloud Community
kenw232
Enthusiast
Enthusiast

How do I shrink and reclaim this space?

I'm trying to shrink a Linux guest which once needed 10GB of space but now only needs 4GB.  I've resized the partitions but no matter what I do the size of the VMDK files are always the same - 10GB.  I've tried all kinds of things to reclaim the space and shrink the vmdk but no matter what I do the size of the vmdk files are always 10GB.  I tried to compact it in VMWare workstations, I tried to run it through "vmware-vdiskmanger -k", I tried importing it into ESX 4 changing the disk type to Thin but nothing.  How do I get the size of the VM (and therefor its vmdk) down to about 4GB which is all its actually using now as shown in the screenshot?

7 Replies
abhilashhb
VMware Employee
VMware Employee

Please follow this KB Article.

It will help you with shrinking the disk on a linux VM running on a Workstation.

VMware KB: Defragmenting and shrinking VMware Workstation virtual machine disks

Abhilash B
LinkedIn : https://www.linkedin.com/in/abhilashhb/

0 Kudos
kenw232
Enthusiast
Enthusiast

This KB article did not help.  I tried compacting, and Disk Clean Up, but with Disk Clean Up it says its unnecessary. 

0 Kudos
a_p_
Leadership
Leadership

Assuming this is a thin provisioned virtual disk, did you zero out the now unallocated disk space from within the guest OS before you resized the partition? The shrink process will only be able to reclaim blocks from the virtual disks which contain only zeroes. If you didn't do this, you may want to temporarily create a new partition, zero out the disk space and remove the partition again before you try to shrink the virtual disk.

André

0 Kudos
kenw232
Enthusiast
Enthusiast

The shrinking of the partition is done.  Hence the screenshot.  Its just empty unallocated partition space.  I can't zero that out from the guest anyway,  well I could but why zero out a partition thats not even defined.  When using a Windows guest, VMware Converter allows you to "Select volumes to copy" and redefine the size that way.  But with Linux guests this "Select volumes to copy" is not supported apparently.    I don't see it.

Does anyone know how to get this "Select volumes to copy" in Vmware Converter to come up for Linux guests?

0 Kudos
VijaySendhur
Enthusiast
Enthusiast

You cant shrink directly even using vmkfstools command, so you have couple of ways to do it

1. Attach another smaller vmdk and move the file to this new disk, detach the old one and reconfigure drive letter in Windows

2. Use vmware converter and do V2V to resize any virtual disk

3. Or use 3rd party tool like QtPartEd to resize

4. Use disk imaging tool like ghost to clone the disk to another smaller disk

0 Kudos
karthikelango
Enthusiast
Enthusiast

Hello,

The only supported method of shrinking a VMware virtual machine disk (VMDK) is to use VMware vCenter Converter Standalone and create a virtual to virtual (V2V) conversion, a similar process to a Physical to Virtual (P2V) conversion.

0 Kudos
bansne
Enthusiast
Enthusiast

the only way i did in my infra was by using converter was able to get vm back to production safetly.