Shrink Thin Provisioned Disks - VMware

KapsZ28

2[H]4U
Joined
May 29, 2009
Messages
2,114
Client has multiple ESXi hosts. Two of them are using local storage and both are nearly out of space. They are all Windows 7 VMs with Thin Provisioning. The amount of space used on the VMs is less than the VMDK file size. So it looks like they used up a lot of space and then deleted it from Windows, but of course the VMDK doesn't shrink when you free up space.

So, how do you go about shrinking the VMDK file and can it be done without shutting down the VM? I can migrate to a NetApp datastore temporarily, but ultimately I need to free up space on the local datastore.
 
Is it possible to move to another datastore as thick eager zero, run sdelete -z, and then move back as thin? It would save a step if it works.
 
This issue is why I now use thick eager zero and add a second HDD to the VM if storage is needed
 
Here's how I do it.

Shrink the free space on the VM to the size you want the drive to be using windows storage manager.
Shutdown the VM in question.
Add another hard drive that is the size you ultimately want your VM to be.
Boot a cloning tool, I use Ghost.
Clone the original disk to your target disk.
After that's finished shut the VM back down.
Go into the edit VM settings.
Select the original hard drive and change its virtual device node to something like SCSI (0:3)
Select the new hard drive and change its virtual device node to SCSI (0:0)
Boot the VM and verify its working properly and the drive size it correct.
Finally remove the original hard drive.

I've done this about 50 times and have never had an issue. Good luck and if you need help let me know.
 
what are your requirements for up time? Can the VM be shut down to move it? What version of vsphere is the client running?
 
The instruction "Child of Wonder" provided worked great.

1. Ran sdelete -z on the Windows OS.
2. Migrate datastore to Thick Eager Zero.
3. Migrate datastore back to Thin.

I reclaimed about 300 GB of space from doing this on 8 VMs.
 
Back
Top