VMware Cloud Community
ali_waqas
Contributor
Contributor

How to reclaim disk space while using thin provision in ESXi 5.5

I have some windows and linux based guest vms with thin provisioning. i deleted data from these guest vms which is approx 200 GB but the datastore shows me only 30 GB space where as these VMs are using only 10 to 20 GB space. Please tell me any solution to reclaim the unused space in ESXi 5.5. My datastore does not support HW Acceleration.

18 Replies
linotelera
Hot Shot
Hot Shot

Have you tried to svmotion each vm? During wizard the system ask for a VM format: choosing thin I thin provisioning svmotion will reclaim effective utilized space from VM...  (only if you have licensed node with enterprise edition)

Reply
0 Kudos
ali_waqas
Contributor
Contributor

I am not using vmotion or svmotion. then how can i reclaim..?

Reply
0 Kudos
linotelera
Hot Shot
Hot Shot

Are you connected to a vcenter or is your node licensed free? If you have a minimum paid licence like essential, you could try to cold migrate change datastore (Power off vm, migrate datastore, choose thin prov, Power on vm).

Otherwise I think there are no solutions.

My best

Reply
0 Kudos
ali_waqas
Contributor
Contributor

I am using vCenter server 5 standard edition license. please let me know if it is possible in this edition and how..?

Reply
0 Kudos
linotelera
Hot Shot
Hot Shot

Then try to cold migrate change datastore:

1.Power off vm

2. migrate datastore

3. choose thin prov

4. After migration complete, power on vm

I think you should move VM between 2 datastore to reclaim your space (shared to local, then local to shared again)

Please let me know if it goes well.

Reply
0 Kudos
ali_waqas
Contributor
Contributor

Ok i will try this way on a test vm as i can not power off my production VMs. is there anyway withour powering off the VMs..?

i have previously tried create the vm into ovf template and then downloaded to the laptop and then uploaded again to the local datastore with thin provisioning but it doesn't work.

Reply
0 Kudos
Wscholz
Enthusiast
Enthusiast

There are a few approaches,

one is the mentioned svmotion to another datastore. If you don´t have another datastore you could use for windows the sysinternals sdelete tool

http://technet.microsoft.com/en-gb/sysinternals/bb897443.aspx

sdelete.exe -z [DRIVE:]


is the command inside the guest. Please be aware that this will expand your disk to the maximum size.


for linux you could use something like this:


dd if=/dev/zero of=/[mounted-volume]/zeroes && rm -f /[mounted-volume]/zeroes


where [mounted-volume] is where you mounted the volume.


After that power off the VM and log in to you your esx. The command


vmkfstools -K [disk].vmdk


where [disk].vmdk is the corresponding disk file of the vm, will shrink the disk.


AFAIK there is no way to do this while the VM is powered on.


Please keep in mind that if the LUN of the datastore is also thin provisioned there is more work to do to free the blocks physically. The following command will do that if your storage system supports vaai scsi unmap:


esxcli storage vmfs unmap -l MyDatastore


I would highly recommend checking out the following KB:


VMware KB: Using esxcli in vSphere 5.5 to reclaim VMFS deleted blocks on thin-provisioned LUNs



------------------------------------------------------------------------- If you found my answer useful please consider marking it as "correct" or "helpful". Thanks a lot
ali_waqas
Contributor
Contributor

Hi

I perform sdelete in windows as you mentioned but it fill the datastore space to maximum and i start receiving alerts of low storage on datastore. when only 13Mb remaining the VM stop responding and i am unable to access the VM guest. please let me know what further actions should i take to solve the issue as now i am unable to access the VM or even i am unable to powered on the VM

Regards

Reply
0 Kudos
Wscholz
Enthusiast
Enthusiast

As i wrote above, sdelete will temporary grow the size of the disk to it´s maximum because it is filling unused space with zeros. So you need temporary space.

------------------------------------------------------------------------- If you found my answer useful please consider marking it as "correct" or "helpful". Thanks a lot
Reply
0 Kudos
linotelera
Hot Shot
Hot Shot

In this case, as indicated by Wscholz try the comand:

vmkfstools -K [disk].vmdk


As indicated here: vSphere 5.5 Documentation Center this comand deallocates all zeroed out blocks and leaves only those blocks that were allocated previously and contain valid data. The resulting virtual disk is in thin format.

Reply
0 Kudos
ali_waqas
Contributor
Contributor

Hi

my disk mount point is /dev/sda5. but i am unable to process this command in linux. please send me an example if i am missing something.

Reply
0 Kudos
ali_waqas
Contributor
Contributor

dd if=/dev/zero of=/dev/sda5 bs=4096 && rm -f /dev/sda5

please tel me the correct syntax of this command as i am unable to process this command.

Reply
0 Kudos
Wscholz
Enthusiast
Enthusiast

Please look at the syntax above. You do not specify the disk device like /dev/sdaXX, you specify the mountpoint and a temporary file. So if you want to zero out /dev/sda5 and /dev/sda5 is mounted as /var then you have to type

dd if=/dev/zero of=/var/mytempfile

After the command errors out you type

rm -f /var/mytempfile

to delete the tempfile

------------------------------------------------------------------------- If you found my answer useful please consider marking it as "correct" or "helpful". Thanks a lot
Reply
0 Kudos
ali_waqas
Contributor
Contributor

Hi Wschoiz

can you briefly explain me how can i use this command. i am explaining you in my scenario.

I copied a 2.2 GB file at this location.

filename: cbt

location: /root

now i run this command to remove the above cbt file so that we can reclaim the deleted unused space

rm -rf /root/cbt

and then i run this command to reclaim the space as you mentioned.

dd if=/dev/zero of=/root/cbt && rm -rf /root/cbt

the result is it created the deleted cbt file to the same location but increase it's size and then gives error no space left. where as it a new test vm and it has 43GB free space and i copied only 2.2 GB file in /root

and it shows me total space 7.5 approx before running all this. i have attached the screen shot

pastedImage_1.png

after running the dd command it created 40G file

pastedImage_2.png

Reply
0 Kudos
Wscholz
Enthusiast
Enthusiast

Hi,

the process is

dd if=/dev/zero of=/cbt

after the command errors out run

rm -rf /cbt

After that, shutdown the VM, login to ESXi Console and run

vmkfstools -K [disk].vmdk


Where [disk].vmdk is the diskfile of your virtual machine where the / partition resides.

------------------------------------------------------------------------- If you found my answer useful please consider marking it as "correct" or "helpful". Thanks a lot
Reply
0 Kudos
ali_waqas
Contributor
Contributor

can you help me how regarding linux guest OS to reclaim space as i am unable to reclaim. if you can give me an example how to reclaim I shall be very thankful to you.

Regards

Reply
0 Kudos
Wscholz
Enthusiast
Enthusiast

the examples are in the posts above. if you get errors pls describe what you mean with "i am unable to reclaim".

------------------------------------------------------------------------- If you found my answer useful please consider marking it as "correct" or "helpful". Thanks a lot
Reply
0 Kudos
ali_waqas
Contributor
Contributor

Reply
0 Kudos