Our customer has VM with CentOS on ESXi host. I have to shrink the disk size of the VM and need to reclaim that free disk space back to ESXi host. Disk type on VM is Thick provisioned.

How to do it?

  • The best way would be to create backup of this VM, create new VM with smaller disk assigned to it and restore backup on new VM. Anyway - you have to do a backup before you do anything with this VM – mrc02_kr Oct 26 '18 at 9:20
  • Please tell us which Linux filesystem – Rui F Ribeiro Oct 26 '18 at 9:25
  • @RuiFRibeiro Filesystem is ext4 – Rajeev Bhandari Oct 26 '18 at 10:23
  • Please tell us the mountpoint too. – Rui F Ribeiro Oct 26 '18 at 10:24

1) In vcenter record current data store 2) on linux server - dd if=/dev/zero of=//0file bs=20971520; rm -f //0file 3) In vcenter - migrate to another data store as Thin Provision (migrate option and check change storage only, then click on advanced button when selecting storage and using pull down that initially says to keep formate - change to thin provisioning) 4) in vcenter - migrate back to original data store from step 1 5) On linux server set up a crontab entry to do fstrim for filesystem (on some systems can set an option in fstab to do fstrim immediately, but I've seen posts that say it can hurt performance).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.