ISO_Datentechni
Contributor
Contributor

How can I shrink a thin provisioned vmdk file?

Hi,

I want to shrink a thin provisioned vmdk file, because in the affected virtual machine OS there are many GBs free, but the thin provisioned disk is nearly the same size like a thick provisioned disk.

Regarding the VMware KB2004155, a SVMotion process to another datastore does not shrink the vmdk file.

I have a vSphere 6 environment with VMFS5 datastores only. So (I think) only a block size of 1MB is possible. Maybe this KB article is a little bit confusing.

Maybe somebody has a good ides how I can shrink a thin provisioned disk?

Thanks and Best Regards,

Andre

0 Kudos
7 Replies
a_p_
Leadership
Leadership

Due to the unified block size of 1MB, Storage vMotion will not help. However, the KB article you mentioned also contains the steps to reclaim zeroed blocks from the thin provisioned disk using the vmkfstools command line utility.

André

0 Kudos
ISO_Datentechni
Contributor
Contributor

Hi André,

but there is no option to reclaim zeroed blocks from the thin provisioned disk without downtime of the affected VM?

Regards,

Andre

0 Kudos
a_p_
Leadership
Leadership

That's unfortunately true. What I could think of - didn't try this myself so far yet - is to Storage vMotion the VM twice (if there's sufficient free space on another datasatore). In the first step select thick provisioned as the target format, and for migrating the VM back to its original datastore, select thin provisioned.

André

0 Kudos
ISO_Datentechni
Contributor
Contributor

Hi André,

this task we have tested already, because my hope also was to shrink the file in that way.

But unfortunately nothiung happened during both SVMotion's...

Regards,

Andre

0 Kudos
a_p_
Leadership
Leadership

Please don't mind me asking, but did you select the target virtual disk format in the wizard, and did you zero out unused blocks within the guest OS using e.g. sdelete as mentioned in the KB article?

What I am thinking of is:

  1. migrate the VM to another datstore, selecting "Thick Provisioned" as the target format
  2. run sdelete within the guest OS to zero out unused blocks
  3. migrate the VM back to the original datastore, selecting "Thin Provisioned" in the wizard

André

0 Kudos
tayfundeger
Hot Shot
Hot Shot

Hi,

Can you shutdown virtual machine and again svMotion (Thick to Thin) ? You can get back unused space only when the virtual machine is turned off.

Thanks.

--
Blog: https://www.tayfundeger.com
Twitter: https://www.twitter.com/tayfundeger

vBlogger, vExpert, Cisco Champions

Please, if this solution helped your problem, "Helpful" if it solves your problem "Correct Answer" to mark.
0 Kudos
vxprthu
Enthusiast
Enthusiast

HI @ISO_Datentechni 

First of all the unused blocks should be zeroed out in the guest vm, then run vmkfstool on the vmdk.:

Example:

sdelete c:/

vmkfstool -K yourcdrives.vmdk

As usual, I recommend to test on a dummy vm first, and/or create a backup of your vm.

Related KB:  https://kb.vmware.com/s/article/2004155

 

PS: Just saw this is an old thread, I don't know why was this on the top of my queue



Blog: vxprt.hu
0 Kudos