Shrink a VMware Virtual Machine Disk (VMDK)



In fact, increasing the size of a VMware Virtual Machine Disk (VMDK) is straightforward, and is supported in the vSphere Client, by selecting the virtual hard disk, and increasing the size using the up arrow. or typing in a new value.

However, you cannot shrink the disk in this way, it’s not supported. The only supported method of shrinking a VMware virtual machine disk (VMDK) is to use VMware vCenter Converter Standalone and create a virtual to virtual (V2V)
conversion, a similar process to a Physical to Virtual (P2V) conversion.

The following procedure should be followed to shrink the VMware VM Disk:

1.      RDP to the VM for which the disk size is to be reduced.
2.      Select Disk Management, and select the partition you need to shrink.
3.      Right Click the Volume/Partition to shrink, and select Shrink.
4.      Enter a size to reduce the OS partition.
5.      In this example the VMware virtual machine disk (VMDK) is 30GB, and we would like to reduce the size of the VMware virtual machine disk (VMDK) to 20GB.
6.       Enter the figure 20 (GB) x 1024 = 20480
7.       Now you can see an unallocated 20 GB space on the virtual disk
8.       Power OFF the Virtual Machine, and navigate to the datastore path where the VMware virtual machine disk (VMDK) is located using Putty
9.       We need to edit the *.vmdk, which is the descriptor file, which contains the variables for the size of the *.-flat.vmdk.
10.  The number mentioned under the heading #Extent description, after the letters RW, defines the size of the VMware virtual disk (VMDK).
11.  We wanted to reduce the size of the VMware virtual machine disk (VMDK) from 40 GB to 20 GB. So the value we need to enter into the descriptor file is:-

20 GB = 20 * 1024 * 1024 * 1024 / 512 = 41943040

12.   Using vi, edit the descriptor file, and change the number from 125829120 to 41943040, and save the file.

125829120 is calculated from 80 GB = 80 * 1024 * 1024 * 1024 / 512 = 125829120

13.   Migrate or Copy the virtual machine to another datastore.
14.   After the virtual machine disk (VMDK) has been moved, you will notice the disk size reflects the desired size of 20GB.
15.   After restarting the virtual machine, and checking with Disk Management, you will notice the 20 GB unallocated storage space, has been removed, and disappeared.

1 comment:

  1. Awesome! Thank you so much for sharing these kinds of information. Keep writing and updating something on MAV Shrink Disc.

    ReplyDelete