Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Virtualization / VMWare / Shrinking VMDK Virtual Disk Size on VMWare ESXi

April 20, 2021 VirtualizationVMWare

Shrinking VMDK Virtual Disk Size on VMWare ESXi

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.

Contents:
  • How to Shrink the Partition Size in the Guest OS?
  • Reduce the VMDK File Size of the VMWare Virtual Machine
  • Shrinking a VMDK Using VMware vCenter Converter Standalone

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.

Shrink a VMware Virtual Machine Disk (VMDK)

Prior to reducing the size of a virtual disk, do the following on your VMWare ESXi host:

  1. Delete all snapshots of the virtual machine (otherwise, you may damage the virtual disk);
  2. Create a full backup of the virtual machine, or create a copy of the vmdk and flat files you want to shrink. Use these commands:
    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:

  • Shrink the partition inside the guest OS;
  • 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?

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.

shrink volume in Windows

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.

specify the amount of space to shrink in MB

Note that the OEM or Windows Recovery partition may sometimes prevent extending or reducing the disk.

windows partition unallocated space

In Linux, you can reduce the partition size using parted. If LVM logical volumes are used, the scenario is different.

Reduce the VMDK File Size of the VMWare Virtual Machine

Then reduce the size of the VMDK file on the VMWare VMFS file system.

  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
    vmware vm file on vmfs datastore
  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.vmdkvmkfstools - 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. new size of the virtual disk is now displayed in the vmware VM properties
  10. Then start the VM, login the guest OS and make sure that the unallocated area has disappeared, and the disk size has been reduced. Shrink a Hard Drive Volume in Windows
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:

  • Reducing the virtual disk size by converting a virtual machine using VMware vCenter Converter. Specify a disk size smaller than the source one to convert it (we will show it in the next section);
  • You can clone virtual disk contents using third-party software (like Acronis True Image or Symantec Ghost32). This task in performed by adding a new smaller disk to the virtual machine and cloning the contents of a larger disk to it. You can remove the larger disk then.

Shrinking a VMDK Using VMware vCenter Converter Standalone

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

Cons:

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

Pros:

  • You don’t need to open the vCenter or ESXi host console;
  • An exact copy of a VM is created;
  • The source disk cannot be damaged in case of any errors in conversion task settings.
Note. The virtual machine you want to convert (change disk size, etc.) must be shut down (using Shut down or Power Off, instead of Suspend).

Specify the ESXi host address.

vmware converter connect vcenter

Select the source VM.

select vm to convert

Set the parameters of your new VM.

set VM properties

Go to the disk edit mode (Data to copy -> Edit).

edit disk properties in vmware converter

Select the copy mode: Select volumes to copy.

copy all disks and mainntain layuout

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.

mainttain disk size vm converter Shrink a VMDK using VMware Converter

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.

Note. In the latest versions of Microsoft Hyper-V, you can use Hyper–V Online VHDX Resize tool to dynamically resize (both expanding and shrinking) virtual disks.

16 comments
3
Facebook Twitter Google + Pinterest
previous post
How to Run Windows File Explorer Elevated (as Administrator)?
next post
Mapped Network Drives are Not Showing in Elevated Programs

Related Reading

Unmounting an NFS Datastore from VMware ESXi

April 21, 2023

How to Increase Virtual Machine Disk Size in...

April 6, 2023

How to Install Free VMware Hypervisor (ESXi)?

January 24, 2023

Using VMware Converter for P2V Migration (Physical to...

October 19, 2022

Using iPerf to Test Network Speed and Bandwidth

September 29, 2022

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Configuring Event Viewer Log Size on Windows

    May 24, 2023
  • How to Detect Who Changed the File/Folder NTFS Permissions on Windows?

    May 24, 2023
  • Enable Single Sign-On (SSO) Authentication on RDS Windows Server

    May 23, 2023
  • Allow Non-admin Users RDP Access to Windows Server

    May 22, 2023
  • How to Create, Change, and Remove Local Users or Groups with PowerShell?

    May 17, 2023
  • Fix: BSOD Error 0x0000007B (INACCESSABLE_BOOT_DEVICE) on Windows

    May 16, 2023
  • View Success and Failed Local Logon Attempts on Windows

    May 2, 2023
  • Fix: “Something Went Wrong” Error When Installing Teams

    May 2, 2023
  • Querying Windows Event Logs with PowerShell

    May 2, 2023
  • Configure Windows LAPS (Local Administrator Passwords Solution) in AD

    April 25, 2023

Follow us

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Adding Drivers into VMWare ESXi Installation Image
  • How to Access VMFS Datastore from Linux, Windows, or ESXi?
  • Hyper-V Virtual Machine Stuck in Stopping/Starting State
  • Match Windows Disks to VMWare VMDK Files
  • Recovering a Deleted VMFS Datastore on VMware ESXi/vSphere
  • Using iPerf to Test Network Speed and Bandwidth
  • How to Install Windows 11 on a Hyper-V Virtual Machine?
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top