# Convert Thick Provisioned Hard Disk to Thin Provisioned in ESXi

## Virtual Disk Types in VMware

- Thick Provision Lazy Zeroed (default) – Space required for the virtual disk is allocated during the creation of the disk file. Any data remaining on the physical device is not erased during creation, but is zeroed out on demand at a later time on first write from the virtual machine. The virtual machine does not read stale data from disk.

- Thick Provision Eager Zeroed – Space required for the virtual disk is allocated at creation time. In contrast to thick provision format, the data remaining on the physical device is zeroed out during creation. It might take much longer to create disks in this format than to create other types of disks.

- Thin Provision – Space required for the virtual disk is not allocated during creation, but is supplied and zeroed out, on demand at a later time.

Source: https://kb.vmware.com/s/article/1022242

## Converting/Cloning to Thin Disk Type

1. Log into the ESXi web UI
2. Enable the SSH service if it is not already enabled by selecting Actions > Services > Enable Secure Shell (SSH) Actions > Services > Enable Secure Shell (SSH)
3. Shutdown the target VM if it is currently running
4. Select the target VM from the left navigation
5. Expand the Hard disk configuration
6. Copy the folder and file name (TurnkeyLinux/TurnkeyLinux.vmdk in this example) and paste into a text document
7. Click the virtual disk .vmdk file name link
8. Copy the location path value displayed (/vmfs/volumes/61a66fb9-5be9b2dc-6d0f-b8ca3a9babec in this example) and paste into a text document
9. Connect to the ESXi host via SSH
10. Run the following commands
    # change directory to the datastore, update path as needed
    # (/vmfs/... path from above)
    cd /vmfs/volumes/61a66fb9-5be9b2dc-6d0f-b8ca3a9babec
    # use vmkfstools to clone the virtual disk to thin provisioned
    # use the folder and file name copied from above
    # syntax
    # vmkfstools -i "<%SOURCE FILE.vmdk%>" -d thin "<%TARGET THIN FILE.vmdk%>"
    vmkfstools -i "./TurnkeyLinux/TurnkeyLinux.vmdk" -d thin "./TurnkeyLinux/TurnkeyLinux-thin.vmdk"
    # after the clone process completes, rename the source (thick) file
    mv "./TurnkeyLinux/TurnkeyLinux.vmdk" "./TurnkeyLinux/TurnkeyLinux.vmdk.thick"
    # rename the target (thin) file to the original .vmdk file name
    mv "./TurnkeyLinux/TurnkeyLinux.vmdk-thin.vmdk" "./TurnkeyLinux/TurnkeyLinux.vmdk"

## Updating the VM Configuration

1. Back in the ESXi web UI, right click on the VM > Unregister > Click Yes to confirm
2. Select Virtual Machines from the left navigation pane > Click Create/Register VM
3. Select Register an existing virtual machine > Click Next
4. Click the Select one or more virtual machines, a datastore, or a directory button > Browse to the virtual machine directory > Select the .vmx > Click Select
5. Click Next and then Finish
6. Select the virtual machine > Click Edit
7. Expand the Hard disk configuration
8. Verify the Type value now shows Thin provisioned
9. Start the VM to verify it boots and runs without issues

## Cleaning Up

1. After fully testing that the VM is functional, select Storage from the left navigation pane
2. Click Datastore browser in the main content area
3. Browse to the virtual machine directory
4. Select the original thick .vmdk file (renamed .vmdk.thick earlier)
5. Click Delete > Click Delete again to confirm the action