Home » Categories » Virtualization » VMware

Shrinking VMDK Virtual Disk Size on VMWare ESXi

Reduce the VMDK File Size of the VMWare Virtual Machine

  1. Shut down the virtual machine you want to reduce disk size;
  2. Using SSH, connect to the console of the ESXi host the VM is registered on (you can use putty or the built-in Windows SSH client);
  3. Go the directory the VMDK file of your VM is located in (you can get a path to it in the virtual disk properties of the vSphere client):
    $ cd /vmfs/volumes/datastore/test-VM



  4. Display the contents of the virtual disk configuration file (*.vmdk) using the cat command:
    $ cat test_vm_3.vmdk
    The size of the vmdk disk is shown in the #Extent description section (after the RW characters). In this case, it is 167772160 (80 GB *1024*1024*1024 / 512);

    vmware vmdk file size

  5. I want to reduce my VMDK disk from 80 to 40 GB. It means that I have to specify 83886080 (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);
  6. I am using vi: 
    $ vi test_vm_3.vmdk

  7. Using the down arrow key, go to the line containing the disk size and press 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;

    shrink vmdk file size on vmware datastore

  8. Then just clone or migrate (using Storage vMotion) the virtual machine to another datastore. After moving the virtual machine files, the new size of its virtual disk will be displayed in its properties.
    Tip. If you have only one ESXi host, one VMFS datastore, you won’t be able to use the Storage vMotion.
    Then you can clone vmdk using this command:
    $ vmkfstools -i test_vm_3.vmdk test_vm_3_newsize.vmdk

    vmkfstools - clone file with reducing file size

    Remove the source VMDK disk, clone the reaming VMDK disk again and rename it by specifying its original name:
    $ rm test_vm_3.vmdk
    $ rm test_vm_3-flat.vmdk
    $ vmkfstools -i test_vm_3_newsize.vmdk test_vm_3.vmdk

  9. Make sure that the new size of the virtual disk is now displayed in the VM properties.

Ref:
http://woshub.com/shrinking-vmdk-virtual-disk-vmware-esxi/

Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Comments Comments
There are no comments for this article. Be the first to post a comment.
Related Articles RSS Feed
Reclaiming disk space from thin provisioned VMDK files on ESXi
Viewed 1591 times since Sun, Feb 27, 2022
Reclaim Used Space with VMKFSTOOLS - Punchzero
Viewed 959 times since Sat, Jan 1, 2022
Convert Thick Provision Lazy Zeroed Disk to Thin on VMware ESXi by vmkfstools
Viewed 565 times since Sat, Jan 1, 2022
Enable content Copy/Paste between VMRC client and Windows/Linux Virtual Machine
Viewed 711 times since Mon, Jan 3, 2022
VMware - Using the OVF Tool to export
Viewed 443 times since Sun, Jan 2, 2022
VMware - Using the OVF Tool deploy
Viewed 470 times since Sun, Jan 2, 2022
OVFTool - Error: SHA digest of file ExortedVM.ovf does not match manifest
Viewed 1763 times since Mon, Jan 3, 2022