In this article we will show how to reduce the size of a virtual disk (vmdk) file of the virtual machine running on VMWare ESXi. Unlike expanding a disk of a VMWare virtual machine you can do on-the-fly without shutting the virtual machine down, it is more complicated to reduce the size of a vmdk file on the VMWare ESXi hypervisor, and you cannot do it via the vSphere Web Client graphical interface. The vSphere Client doesn’t allow you to specify a smaller virtual disk size.
Important. This guide is not an officially supported solution on how to reduce the size of vmdk disks in VMWare. However, I used this method dozens of times. VMWare ESXi 6.7 is used in this article.
Prior to reducing the size of a virtual disk, do the following on your VMWare ESXi host:
cp vmname.vmdk backup_vmname.vmdk
cp vmname-flat.vmdk backup_vmname-flat.vmdk
The procedure of reducing a virtual disk size consists of two steps:
First of all, reduce the size of the disk partition in the guest operating system. If your virtual machine is running Windows OS, use the Disk Manager
diskmgmt.msc (the Shrink Volume operation is available in all supported Windows versions;
sdelete tool is used in older Windows versions to reduce the partition size) or third-party tools (like Acronis Disk Director). If you don’t do it, after then your file system may crash after shrinking the virtual disk size.
Suppose, you want to reduce the disk size by 40 GB. So the volume size must be reduced by 40960 MB (
40 GB x 1024). Enter this value in the corresponding field of the Shrink Volume wizard. After reducing the partition size, there will be some unallocated space (40 GB in our example) to the right of your partition.
In Linux, you can reduce the partition size using parted. If LVM logical volumes are used, the scenario is different.
Then reduce the size of the VMDK file on the VMWare VMFS file system.
# cat test_vm_3.vmdk
80 GB *1024*1024*1024 / 512);
40 GB*1024*1024*1024 / 512) in the Extent description section. Set a new size of your virtual disk using a text editor (vi or nano);
# vi test_vm_3.vmdk
i(to edit it). Specify the new size of the virtual disk. Press ESC to exit the edit mode and then type
:wq-> Enter to save the changes;
vmkfstools -i test_vm_3.vmdk test_vm_3_newsize.vmdk
vmkfstools -i test_vm_3_newsize.vmdk test_vm_3.vmdk
Tip. If you have used vmkfstools in the previous step, reconnect the virtual disk in the VM settings, since its new size may not be displayed correctly.
Note. The following methods are often used to reduce the size of VMDK disks:
Another way to reduce a virtual disk size of a VMWare virtual machine is to use a free GUI tool VMware vCenter Converter Standalone.
Note. The virtual machine you want to convert (change disk size, etc.) must be shut down (using Shut down or Power Off, instead of
Specify the ESXi host address.
Select the source VM.
Set the parameters of your new VM.
Go to the disk edit mode (Data to copy -> Edit).
Select the copy mode: Select volumes to copy.
Specify the new disk size for your new VM. As you can see, 48 GB is occupied in the guest OS, and the disk size is 150 GB. We will reduce the size of the virtual disk to 60 GB.
Run the VM conversion process. Then you can power off the source VM and power on the new one. Make sure that the disk size has been reduced. After that the original VM may be removed.