Bobcares

Shrink VMDK Virtual Disk Size on VMWare ESXi – How to do it

by | Apr 22, 2021

Unlike expanding a disk of a VMWare virtual machine, it is more complicated to shrink VMDK Virtual Disk Size on the VMWare ESXi hypervisor.

It is impossible to do it via the vSphere Web Client graphical interface. It does not allow to specify a smaller virtual disk size.

As part of our Server Management Services, we assist our customers with several VMWare queries.

Today, let us see how to reduce the size of a virtual disk (vmdk) file of the virtual machine running on VMWare ESXi.

 

Shrink VMDK Virtual Disk Size on VMWare ESXi

Before we reduce the size, we need to do the following on the VMWare ESXi host:

  1. Delete all snapshots of the virtual machine not to damage the virtual disk
  2. Create a full backup of the virtual machine or a copy of the vmdk and flat files we want to shrink.
    cp vmname.vmdk backup_vmname.vmdk
    cp vmname-flat.vmdk backup_vmname-flat.vmdk

Shrink VMDK Virtual Disk Size on VMWare ESXi

The process to reduce a virtual disk size consists of two steps:

  1. Shrink the partition inside the guest OS
  2. Reduce the size of the VMDK file of the VMWare virtual machine on the VMFS (NFS) datastore.

 

How to Shrink the Partition Size in the Guest OS?

Initially, we need to reduce the size of the disk partition in the guest operating system.

If the virtual machine runs Windows OS, we use the Disk Manager diskmgmt.msc or third-party tools. Failure of which may lead to a file system crash.

For instance, if we want to reduce the disk size by 40 GB, the volume size must reduce by 40960 MB (40 GB x 1024). We enter this value in the corresponding field of the Shrink Volume wizard. Once done, there will be some unallocated space to the right of our partition.

 

Reduce the VMDK File Size of the VMWare Virtual Machine

In order to reduce the size of the VMDK file on the VMWare VMFS file system, our Support Techs suggests the following steps:

  1. Initially, we shut down the virtual machine we want to reduce disk size.
  2. Via SSH, we connect to the console of the ESXi host the VM is registered on
  3. Then we go to the directory the VMDK file of our VM is located in:
    cd /vmfs/volumes/datastore/test-VM
  4. We display the contents of the virtual disk configuration file (*.vmdk) using the cat command:
    # cat test_vm_3.vmdk
  5. The size of the vmdk disk is shown in the #Extent description section.
  6. To reduce the VMDK disk from 80 to 40 GB, we have to specify 83886080 in the Extent description section. Set the new size of the virtual disk using a text editor.
    For example,

    # vi test_vm_3.vmdk
  7. From the down arrow key, go to the line containing the disk size. Specify the new size, save the changes and close the file.
  8. Then we clone or migrate the virtual machine to another datastore. Once we move the virtual machine files, the new size of its virtual disk will display in its properties.
  9. Ensure the new size displays in the VM properties.
  10. Then start the VM, log in to the guest OS, and make sure that the unallocated area has disappeared and the disk size has been reduced.

 

Shrink a VMDK Using VMware vCenter Converter Standalone

GUI tool VMware vCenter Converter Standalone is another way to reduce a virtual disk size of a VMWare virtual machine.

Pros:

  • V2V conversion is slow
  • Need enough space on the datastore to save the new VM
  • The new virtual machine will have a new MAC address.

Cons:

  • We do not need to open the vCenter or ESXi host console
  • Creates an exact copy of a VM
  • The source disk cannot be damaged in case of any errors in conversion task settings.

Instead of Suspend, we have to Shut down the virtual machine we want to change the disk size.

  1. Initially, we specify the ESXi host address and select the source VM.
  2. Then we set the parameters of the new VM.
  3. Go to the disk edit mode (Data to copy -> Edit).
  4. Select the copy mode: Select volumes to copy.
  5. We specify the new disk size for the new VM.
  6. Once we run the VM conversion process, we can power off the source VM and power on the new one.
  7. Ensure the disk size has been reduced. After that, we can remove the original VM.

[Need help to shrink the size? We’d be happy to assist]

 

Conclusion

In short, we saw how our Support Techs shrink VMDK Virtual Disk Size on VMWare ESXi.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

3 Comments

  1. Peter De Groote

    Hello,
    the disk size has been reduced, but the unallocated area has NOT disappeared in OS.
    It is still showing in disk management.
    how can we get rid of this?
    regards
    Peter

    Reply
    • Hiba Razak

      Hi,

      Our Experts can help you with the issue, we’ll be happy to talk to you on chat (click on the icon at right-bottom).

      Reply
    • Carem Liyim

      If you are using Linux

      Download gparted live cd and boot from it.
      Once loaded use the Gparted gui to reduce the GuestOS size

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.