How to Reclaim Disk Space From VMware Virtual Machine

User Author

Achilles.H

May 24, 2024

How to Reclaim Disk Space From VMware Virtual Machine

The disk space occupied by virtual machines becomes bigger and bigger as time goes by. However, even if we delete files from the virtual machines, the host disk space occupied by the virtual machines remains unchanged. When we delete files in a virtual machine, only the guest OS knows this space is free, and the host OS is unaware of this until we take steps to reclaim disk space. This post provides three methods to solve this issue. Let's explore it.

Way 1: Reclaim Disk Space from Windows Guest

Before shrinking, verify that these prerequisites are met.

Note: Compression is only available for dynamically expanding virtual disks. Pre-allocated disks of fixed size cannot be compressed. The host must have sufficient space for compression (larger than the disk space occupied by the VM).

Step 1: Power off the VM you want to reclaim disk space from.

Step 2: Select this VM from the Library, then click "Edit virtual machine settings" option in the main panel.

Step 3: Click the Hard Disk item under the Hardware tab of the Virtual Machine Settings window.

Step 4: Select "Compact" option to compact disk.

compact option position demo

Step 5: After the compact process is complete, you will get the unused disk space back.

Note: Alternatively, you can use the "clean up disks" option to free up unused disk space. Right-click on the virtual machine from the Library, then select Manage > Clean Up Disks.

clean up disks

Way 2: Reclaim Disk Space from Linux Guest

If you have installed the "VMware Tools" on your guest, you can free up host disk space occupied by the deleted files in guest following these steps.

Step 1: Start the corresponding virtual machine.

Step 2: Open terminal by pressing "Ctrl + Alt + T" shortcut key.

Step 3: Run the following commands:

sudo /usr/bin/vmware-toolbox-cmd disk list

sudo /usr/bin/vmware-toolbox-cmd disk shrink /

Note the space between "shrink" and "/".

vmware toolbox cmd shrink

Step 4: Wait for the shrinking process to complete. The unused disk space is freed up.

Note: The demo guest operating system is Ubuntu, and the operations on other Linux distributions are similar.

Way 3: Reclaim Disk Space Using VMware-Vdiskmanager Tool

The vmware-vdiskmanager.exe tool can also free up unused disk space. This tool is located at the VMware's installation directory. Generally, the default installation directory is C:\Program Files(x86)\VMware\VMware Workstation\. You can use this tool to perform various operations on virtual machine hard disks. If the above methods is invalid, you can try this.

Step 1: Shut down the corresponding virtual machine.

Step 2: Locate to the VMware's installation directory in File Explorer.

Step 3: Open the Command Prompt by typing "cmd" in the address bar of the File Explorer.

open command prompt from installation directory

Step 4: Run the following command to shrink the virtual hard disk.

vmware-vdiskmanager.exe -k "D:\xxx\Virtual-Machines\Windows11-64-pro-23h2\Windows11-64-pro-23h2.vmdk"
vdiskmanager tool shrink complete

Note: Replace the underlined part with the actual path of virtual hard disk file. You can get the actual path following the steps: Press Shift key, and right click this virtual hard disk file, then select copy as path option from the context menu.

copy as path

Step 5: Wait for the process to complete.

Conclusion

This post provides three methods to reclaim disk space from VMware virtual machines. Try to reclaim your disk space following the method best suits you. Hope this post is helpful to you.