Convert vSphere VM From Thick to Thin Provisioning
If you’re using vSphere and want to optimize storage usage by converting a VM from thick to thin provisioning, this blog post will guide you through the process. Thin provisioning allows you to allocate storage space dynamically, resulting in efficient utilization of your storage resources. We’ll walk you through the steps for converting the VM from thick to thin provisioning.
Prerequisites
Before proceeding, make sure you have the following:
- Access to vSphere management interface.
- Administrative privileges to perform VM-related operations.
Converting/Cloning to Thin Disk Type
Follow these steps to convert the VM to thin provisioning:
- Log into the vSphere web UI.
- Enable the SSH service if it is not already enabled. Go to Actions ≫ Services ≫ Enable Secure Shell (SSH).
- Shut down the target VM if it is currently running.
- Select the target VM from the left navigation.
- Expand the “Hard disk configuration” section.
- Copy the folder and file name (e.g., WIN10PC/WIN10PC.vmdk) and paste it into a text document for reference at a later time.
- Click on the virtual disk (.vmdk) file name link.
- Copy the location path value displayed (e.g., /vmfs/volumes/5a0ce14d-5574951d-af28-4ccc6a87617d) and paste it into the text document.
- Connect to the ESXi host via SSH.
- Run the following commands:
# Change the directory to the datastore (update path as needed)
# (/vmfs/... path from above)
cd /vmfs/volumes/5a0ce14d-5574951d-af28-4ccc6a87617d
# 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 "./WIN10PC/WIN10PC.vmdk" -d thin "./WIN10PC/WIN10PC-thin.vmdk"
# After the clone process completes, rename the source (thick) file
mv "./WIN10PC/WIN10PC.vmdk" "./WIN10PC/WIN10PC.vmdk.thick"
# Rename the target (thin) file to the original .vmdk file name
mv "./WIN10PC/WIN10PC-thin.vmdk" "./WIN10PC/WIN10PC.vmdk"
Updating the VM Configuration
Follow these steps to update the VM configuration:
- Back in the vSphere web UI, right-click on the VM and select “Unregister” and confirm.
- Select “Virtual Machines” from the left navigation pane and click “Create/Register VM.”
- Select “Register an existing virtual machine” and click “Next.”
- Click the “Select one or more virtual machines, a datastore, or a directory” button and browse to the virtual machine directory.
- Select the .vmx file and click “Select.”
- Click “Next” and then “Finish.”
- Select the virtual machine and click “Edit.”
- Expand the “Hard disk configuration” section.
- Verify that the “Type” value now shows “Thin provisioned.”
- Start the VM to ensure it boots and runs without any issues.
Cleaning Up
Follow these steps to clean up the old thick provisioned files:
- After fully testing that the VM is functional, select “Storage” from the left navigation pane.
- Click “Datastore browser” in the main content area.
- Browse to the virtual machine directory.
- Select the original thick .vmdk file (WIN10PC.vmdk.thick earlier).
- Click “Delete” and confirm the action. Alternatively, you can run the following commands from the server’s host terminal:
cd /vmfs/volumes/5a0ce14d-5574951d-af28-4ccc6a87617d/WIN10PC rm -rf WIN10PC.vmdk.thick
VIP: BE CAREFUL ON THE NEXT STEP
- Rename the “WIN10PC-flat.vmdk” file:
mv WIN10PC-flat.vmdk WIN10PC-flat.vmdk.OLD
- Launch the VM to ensure that it turns on successfully. If it does, proceed to the final step.
- Delete the old “WIN10PC-flat.vmdk.OLD” and keep the “WIN10PC-thin-flat.vmdk” file. If you skip this step, extra storage will be allocated on the storage device.
rm -rf WIN10PC-flat.vmdk.OLD
Congratulations! You have successfully converted a vSphere VM from thick to thin provisioning. By doing so, you have optimized your storage utilization and improved resource efficiency.