Thin Provisioning a ESXi VM

 

This is from- https://www.reddit.com/r/homelab/comments/78p8lh/how_to_convert_disk_from_thick_to_thin/

Recently I was need needing to clone a VM and found a way to do it by copying  a VM to another folder and then turning it on which works but the copied VM is Thick Provision on the copy so no good for small lab test environment. So I found this to test.


How to convert disk from Thick to Thin provisioned in free ESXi

I've had a few VMs which had thick provisioned disks instead of thin, as thick is the default this is quite easy to do.

If you have the paid version of vSphere and two or more hosts managed by vCenter you can simply do a storage vMotion and change the destination disk to thin.

I, like most of the people in this sub, run the free ESXi so this isn't possible. I'll show you how to do it in ESXi via the CLI. I did this on 6.5 but it should work for most versions.

  1. Ensure VM you want to convert is powered down.

  2. Enable SSH via the GUI (Host > Manage > Services > TSM-SSH > Start)

  3. SSH into the host.

  4. Navigate to the VM folder under /vmfs/volumes/ - cd /vmfs/volumes/VM Store/vm01

  5. Clone the vmdk to a thin provisioned disk using vmkfstools - vmkfstools -i vm01.vmdk -d thin thin-vm01.vmdk

  6. Rename old flat file - mv vm01-flat.vmdk vm01-flat.vmdk.old

  7. Rename new flat file - mv thin-vm01-flat.vmdk vm01-flat.vmdk

  8. Unregister VM from ESXi inventory, this is necessary for the host to recognise the new disk type (Right-click VM > Unregister)

  9. Re-register the VM (Create / Register VM > Register an existing virtual machine)

  10. Boot the VM and check all is well.

  11. Delete unnecessary vmdk files - rm thin-vm01.vmdk && rm vm01-flat.vmdk.old

Hope this helps somebody!

______________________________________________

Oh and this too-


Also, if you have used and then deleted contents then you may need to run a tool like sdelete to let VMware know that the blocks can be reclaimed, This reduces space used by my thin disks. Technique is sometimes know as whole punching:

https://tinkertry.com/how-to-manually-free-up-vmfs-space-after-deleting-big-files-in-a-thin-provisioned-windows-vm

Comments

Popular posts from this blog

Clearing DNS cache on vCenter Server Appliance

Repairing a virtual disk in Workstation (2019259)