VMware Cloud Community
nstiglitz
Contributor
Contributor

Shrinking a thin provisioned vmdk


I guess I'm looking for a definitive answer on this.  Upon taking a new job, there's a branch office that has an ESXi 5.1 server.  On it there is datastore1 and datastore2.  Datastore1 was created before we were in the picture, and for some reason the person that created it provisioned the vmdk to be the size of the datastore itself.  Needless to say the datastore has filled up in the past, crashing the VM.  I've been able to partially use SDelete and vmkfstools, but since SDelete fills out the vmdk, it fails eventually, but running vmkfstools allows me to recover some of the space.  At one point I had created 50GB of free space, but another issue that's occurring, is the vmdk will continue to grow even the client OS, Server 2003 R2 has 160GB of free space.  So I guess I have two questions, one why is the vmdk growing when it doesn't need to?  Second, what are my options to shrink this vmdk?  For a little more background, this is just a stand alone ESXi host with vSphere Client.

Reply
0 Kudos
8 Replies
Shrikant_Gavhan
Enthusiast
Enthusiast

Hi nstiglitz,

When you run sDelete inside the OS, after the command execution you can see that the virtual machine disk utilization looks like you have thick disk provisioned.

that means it punch zero's inside the free looking blocks. That is the reason it takes complete disk space as size of underlying LUN (which is the actual disk space provided to VM disk)

To shrink this vm disk, please check if you can migrate this VM to another LUN with enough free space or you can extend the existing LUN with little more space and then try to sDelete.

Other way is , you can decrease the virtual machine RAM to some extent which can again free up some space on the LUN as it takes space for vm swap file.

Thanks and Regards,

Shrikant Gavhane.

Thanks and Regards, Shrikant Gavhane
Reply
0 Kudos
nstiglitz
Contributor
Contributor

First, thank you for the response.  I did know that SDelete basically fills out the entire vmdk, but then running vmkfstools allowed me to reclaim some of the free space and shrink the vmdk back down.  The issue is, the vmdk itself is still provisioned  to grow that original size, and keeps growing even though the VM OS has plenty of free space itself.  Is there a way to troubleshoot why the vmdk is growing?  I've thought about moving it, but unfortunately the other datastore isn't big enough.  We do have a NAS there, is there a way to add a datastore that sits on a NAS to an ESXi host?  What about VMWare Converter, is that an option?  I suppose we could add some SCSI attached storage, but that's an expensive option for a VM that will eventually be decommisioned eventually.

Reply
0 Kudos
nstiglitz
Contributor
Contributor

Sorry, thinking out loud to myself, and forgive me if have something incorrect, I'm not overally familiar with VMWare yet.  I should be able to add a NFS datastore on our NAS, correct?  If I do that, then I could move it to there, or could potentially use VMWare Converter.

Reply
0 Kudos
King_Robert
Hot Shot
Hot Shot

Two popular tools are available for VMDK shrink: SDelete and Shrink Disks, a VMware Tools offering. VMware Tools is a free set of drivers, services and user processes that's installed in a guest OS. VMware Tools' shrink functionality cannot be scripted, so the operator needs to run this process. To run a VMDK shrink, VMware Tools stuffs the virtual disk with zero-filled files. If you have to interrupt or stop the shrink for any reason, these zero-filled files are left behind.

SDelete, a command-line tool that Mark Russinovich created and Microsoft offers for free can be scripted and performs a VMDK shrink differently than VMware Tools. SDelete random-fills a hard drive to delete data securely. It allocates the largest file and cached file it can, hogging free space on the disk to perform a secure cleanse without affecting any operating files.

A third option was suggested by blogger vNoob: a PowerCLI script. Using this method, a script connects to the data store, grabs and copies the VMDK header file locally, changes the file and copies it back up. After this script is complete, a cold storage migration is needed for it to take effect. Be sure to read over vNoob's disclaimers before trying this method and test it on a clone first.

Reply
0 Kudos
nstiglitz
Contributor
Contributor

@King_Robert

If I'm understanding, I would install VMWare Tools on the virtual machine, so on the Server 2003 OS, and not on ESXi, correct?

Reply
0 Kudos
homerzzz
Hot Shot
Hot Shot

Yes, one option is use Vmware Converter, convert the vm and resize the vmdk during the conversion and select the NFS datastore (if you create one) as the destination datastore. Once the "new" vm is up and running fine, you can get rid of the original vm.

Reply
0 Kudos
nstiglitz
Contributor
Contributor

I'm trying to look into the Shrink Disks within VMWare Tools, but when I double click on the icon, it just brings up an About VMWare Tools.  How do I actually access the utilities?

Reply
0 Kudos
homerzzz
Hot Shot
Hot Shot

You have to use the VMwareToolboxCmd now:

C:\Program Files\VMware\VMware Tools

Reply
0 Kudos