We like to install Windows 11 on a Virtual Machine (VM). After booting from the…
Convert thick provisioned disk to thin on VMware ESXi
You want to save disk space and convert thick provisioned disk to thin on VMware ESXi 6.7. It’s good to know that there are three disk types in VMware. Thick provision eager zeroed, thin provision and thick provisioned lazily zeroed, which is the default. You get the task to save disk space on the datastore, and the best advice is to convert thick provisioned to thin on VMware ESXi. What are the options to convert from thick provisioned lazy zeroed disk to thin, and how to do that?
Table of contents
- VMware disk types
- How to convert thick provisioning to thin
- Convert thick provisioned to thin with vmkfstools in ESXi Shell (command line)
- Step 1. Check VMware hard disk type
- Step 2. Shut down VM
- Step 3. Enable SSH on VMware ESXi host
- Step 4. SSH into the ESXi host
- Step 5. Navigate to the VM folder
- Step 6. Clone the VMDK to a thin provisioned disk using vmkfstools
- Step 7. Rename old flat file
- Step 8. Rename new flat file
- Step 9. Unregister VM from ESXi
- Step 10. Register VM in ESXi
- Step 11. Verify hard disk type conversion
- Step 12. Start the VM
- Step 13. Delete unnecessary VMDK files
- Conclusion
VMware disk types
- Thick Provision Lazy Zeroed: is a disk that takes all of its space at the time of its creation, but this space may contain some old data on the physical media. This old data is not erased or written over, so it needs to be “zeroed out” before new data can be written to the blocks. This type of disk can be created more quickly, but its performance will be lower for the first writes due to the increased IOPS (input/output operations per second) for new blocks.
- Thick Provision Eager Zeroed: is a disk that gets all of the required space still at the time of its creation, and the space is wiped clean of any previous data on the physical media. Creating eager zeroed disks takes longer, because zeroes are written to the entire disk, but their performance is faster during the first writes. This sub-type of thick-provisioned virtual disk supports clustering features, such as fault tolerance.
- Thin Provision: Thin provisioning is another type of storage pre-allocation. A thin-provisioned virtual disk consumes only the space that it needs initially, and grows with time according to demand.
Read more about Thick and Thin Provisioning: What Is the Difference?
How to convert thick provisioning to thin
Convert thick disk provisioning to thin on VMware ESXi with the options:
- VMware converter
- VMware vCenter (vMotion)
- VMware command line (this article)
If you do have vCenter configured, it’s best to move a VM with VMotion and select the virtual disk format Thin Provision in the wizard. You can use VMware converter or command line if you don’t have vCenter, you only have one ESXi host, or don’t want to spend a license to get more features.
Convert thick provisioned to thin with vmkfstools in ESXi Shell (command line)
In this step by step guide, you will learn how to convert a thick provisioned lazy zeroed disk to thin on VMware ESXi 6.7. The steps are the same for other ESXi versions. You will use the vmkfstools command.
The vmkfstools command offers the ability to clone virtual machine content and also convert from one virtual machine disk (.vmdk) format into another.
Read the VMware documentation about cloning and converting virtual machine disks with vmkfstools.
Step 1. Check VMware hard disk type
Log in to VMware ESXi. Click in the left menu on Virtual Machines. In the Virtual Machine list view, right-click on the VM and click Edit Settings.
Good to check is the VM used space. The used space column shows the VM as 60 GB used space.
Expand the Hard disk and check the Type. The hard disk type is thick provisioned, lazily zeroed.
Step 2. Shut down VM
Shut down the VM that you want to convert if you did not do that already.
Virtual machine disk files are locked while in-use by a running virtual machine.
Step 3. Enable SSH on VMware ESXi host
Enable SSH via the GUI. Expand Host and click on Manage. Click the tab Services and find the service name TSM-SSH. Click on Start.
An information banner will show up that the service TSM-SSH successfully started.
Step 4. SSH into the ESXi host
SSH into the host with the application Putty.
Log in with the user privileges account.
login as: root
Keyboard-interactive authentication prompts from server:
| Password:
End of keyboard-interactive prompts from server
The time and date of this login have been sent to the system logs.
WARNING:
All commands run on the ESXi shell are logged and may be included in
support bundles. Do not provide passwords directly on the command line.
Most tools can prompt for secrets or accept them from standard input.
VMware offers supported, powerful system administration tools. Please
see www.vmware.com/go/sysadmintools for details.
The ESXi Shell can be disabled by an administrative user. See the
vSphere Security documentation for more information.
Step 5. Navigate to the VM folder
Navigate to the VM folder under /vmfs/volumes/ with the command cd vmfs/volumes.
[root@localhost:~] cd vmfs/volumes
List the name of the VM store with ls -lh
total 1792
drwxr-xr-x 1 root root 8 Jan 1 1970 5c0b0ded-b7a4a6f0-3ff8-6d6c6426e4f1
drwxr-xr-t 1 root root 76.0K Jan 5 20:06 5e88aaf7-7ab335e2-4adc-1c697a0f86bd
drwxr-xr-x 1 root root 8 Jan 1 1970 5e88eeda-f0c3ecce-d429-1c697a0f86bd
drwxr-xr-x 1 root root 8 Jan 1 1970 62577ee5-b5de7369-1044-083e27a116b0
lrwxr-xr-x 1 root root 35 Jan 5 20:42 datastore01 -> 5e88aaf7-7ab335e2-4adc-1c697a0f86bd
Change to the directory of the datastore. In this example, cd datastore01.
[root@localhost:/vmfs/volumes] cd datastore01
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd]
List the VM names in the datastore with ls -lh.
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd] ls -lh
total 1024
drwxr-xr-x 1 root root 72.0K Jan 5 19:08 DC01-2016
drwxr-xr-x 1 root root 76.0K Jan 5 19:14 EX01-2016
drwxr-xr-x 1 root root 76.0K Jan 5 19:08 EX02-2016
drwxr-xr-x 1 root root 76.0K Jan 5 20:02 FS01-2016
drwxr-xr-x 1 root root 72.0K Jan 5 20:06 ISO
drwxr-xr-x 1 root root 72.0K Jan 5 19:08 KLB01
drwxr-xr-x 1 root root 72.0K Jan 5 19:17 PC01
Change to the directory of the VM. In this example, it’s the file server FS01-2016. Run the command cd FS01-2016.
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd] cd FS01-2016
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd/FS01-2016]
Run the command ls -lh to list the files in the directory.
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd/FS01-2016] ls -lh
total 62916608
-rw------- 1 root root 60.0G Jan 5 22:04 FS01-2016-flat.vmdk
-rw------- 1 root root 264.5K Jan 5 22:04 FS01-2016.nvram
-rw------- 1 root root 450 Jan 5 21:58 FS01-2016.vmdk
-rw-r--r-- 1 root root 0 Jan 5 21:58 FS01-2016.vmsd
-rwxr-xr-x 1 root root 3.2K Jan 5 22:04 FS01-2016.vmx
-rw-r--r-- 1 root root 226.5K Jan 5 22:04 vmware.log
Step 6. Clone the VMDK to a thin provisioned disk using vmkfstools
Use the command vmkfstools -i FS01-2016.vmdk -d thin FS01-2016-thin.vmdk.
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd/FS01-2016] vmkfstools -i FS01-2016.vmdk -d thin FS01-2016-thin.vmdk
Destination disk format: VMFS thin-provisioned
Cloning disk 'FS01-2016.vmdk'...
Clone: 100% done.
List the files in the directory and verify that two files are created: FS01-2016.thin-flat.vmdk and FS01-2016.thin.vmdk.
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd/FS01-2016] ls -lh
total 72898560
-rw------- 1 root root 60.0G Jan 5 22:04 FS01-2016-flat.vmdk
-rw------- 1 root root 60.0G Jan 5 22:07 FS01-2016-thin-flat.vmdk
-rw------- 1 root root 504 Jan 5 22:07 FS01-2016-thin.vmdk
-rw------- 1 root root 264.5K Jan 5 22:04 FS01-2016.nvram
-rw------- 1 root root 450 Jan 5 21:58 FS01-2016.vmdk
-rw-r--r-- 1 root root 0 Jan 5 21:58 FS01-2016.vmsd
-rwxr-xr-x 1 root root 3.2K Jan 5 22:04 FS01-2016.vmx
-rw-r--r-- 1 root root 226.5K Jan 5 22:04 vmware.log
Step 7. Rename old flat file
Rename the old file with the command mv FS01-2016-flat.vmdk FS01-2016-flat.vmdk.old.
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd/FS01-2016] mv FS01-2016-flat.vmdk FS01-2016-flat.vmdk.old
Step 8. Rename new flat file
Rename the thin flat file with the command mv FS01-2016-thin-flat.vmdk FS01-2016-flat.vmdk.
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd/FS01-2016] mv FS01-2016-thin-flat.vmdk FS01-2016-flat.vmdk
Step 9. Unregister VM from ESXi
This is necessary for the host to recognize the new disk type. Right-click VM > Unregister.
Click Yes.
Step 10. Register VM in ESXi
Click on Create / Register VM.
Select Register an existing virtual machine. Click on Next.
Click on Select one or more virtual machines, a datastore, or a directory.
Open the VM FS01-2016 and select the FS01-2016.vmx file. Click Select.
Click on Next.
Click Finish.
Step 11. Verify hard disk type conversion
Check the VM hard disk size. In this example, the hard disk changed from 60 GB to 9.56 GB.
Right-click on the VM and select Edit Settings.
Expand hard disk and check the Type. It shows as Thin provisioned.
Step 12. Start the VM
Start the VM and check that everything works as expected.
Step 13. Delete unnecessary VMDK files
Clean up and remove the files. Run the command rm FS01-2016-thin.vmdk && rm FS01-2016-flat.vmdk.old.
[root@localhost:/vmfs/volumes/5e88aaf7-7ab335e2-4adc-1c697a0f86bd/FS01-2016] rm FS01-2016-thin.vmdk && rm FS01-2016-flat.vmdk.old
Conclusion
In this article, you learned how to convert thick provisioned disk to thin on VMware ESXi. Check the disk type before you start to convert from thick to thin disk in the command line interface. Verify the conversion at the end and start up the system to make sure all is working.
Did you enjoy this article? You may also like Install Kemp virtual load balancer on VMware. Don’t forget to follow us and share this article.
This is a wonderful step-by-step article and saved me a half TB of space on VM’s that were over-provisioned.
Thank you.
Thanks very much. It is a great tutorial.
Great instructions. Really appreciate you taking the time to construct this.
Thank you for sharing 🙂
Hey,
Thanks for your nice tutorial!
I also tried to follow your instructions but I seem to have another problem. My vm says it has a thin provisioned disk 80GB in vm properties (real disk usage 14,8 of 80 GB in Windows) but it still shows used space 80 GB in vmware. Do you know what could cause this problem?
Thank you so much in advance!
Thank You. It’s helpful and good instruction.
Thank you very helpful
My storage is completely full as is? How do I do this if I don’t have the space to make a copy of the VM?
Very helpful…much appreciated!
Thanks and excellent write-up. It worked great for me on an esxi 6.7 with update 3 host.
thank you for your post, some additional information for ESXi6.7
– If you have multiple vmdk files (i.e XX-00001.vmdk) shut down the vm and go to Snapshot > Consolidate disks. This will reduce it to the original vmdk file.
– In my case, I was not able to start the VM. So i try around and find out that I only need to replace the new XX-flat.vmdk file. Then I was able to start the VM
Thanks for the tutorial!
Cola, your 6.7 findings did it for me as well. Just do not replace the XX.vmdk, only replace the XX-flat.vmdk fixed the system from not recognizing the disk.