Defragmenting, shrinking, and cleaning up VMware Fusion virtual machine disks
search cancel

Defragmenting, shrinking, and cleaning up VMware Fusion virtual machine disks

book

Article ID: 328883

calendar_today

Updated On:

Products

VMware Desktop Hypervisor

Issue/Introduction

You may be able to reduce the size of a VMware Fusion virtual machine's sparse disk if it does not have any snapshots. This article provides information on defragmenting the virtual hard drive from within Windows, shrinking the virtual disk from within Windows and Linux, and cleaning up (defragmenting) the virtual disk in Mac OS.

Note: It is not possible to reduce the size of a Fusion virtual machine's pre-allocated disk. The size of a pre-allocated disk is always approximately equal to the size allocated to the virtual machine's operating system.

A sparse disk is equal in size to the space the guest operating system has used. This size is not necessarily the same as the space that the guest operating system is currently using. This is because, when you tell an operating system to delete a file, it does not actually delete the file instead it stops remembering what is stored in the space that was used by the file. This is similar to having an unlabeled VCR tape or rewritable CD/DVD. If there is no label, the presumption is that you are free to record on it. So, when a file is deleted, the guest operating system stops marking that space as used. However, the data is not removed from the disk and so Fusion still counts it. Defragmenting and then shrinking the disk is necessary to free up this space that's no longer being used.


Environment

VMware Fusion 4.x
VMware Fusion 10.x
VMware Fusion 11.x
VMware Fusion Pro 10.x
VMware Fusion 8.x
VMware Fusion 2.x
VMware Fusion 7.x
VMware Fusion 5.x
VMware Fusion Pro 11.x
VMware Fusion 6.x
VMware Fusion Pro 8.x
VMware Fusion 3.x

Resolution

Fusion virtual machines can be pre-allocated or sparse. In a pre-allocated virtual machine, the size of the virtual disk file (or files, if you have chosen to split the virtual machine into 2 GB files) is equal to the size of the virtual machine. In a sparse virtual machine, the size of the virtual disk file (or files) is equal to the total used space of the virtual machine.

Your virtual machine bundle is always larger than the size of your virtual disks because the bundle contains snapshots, suspend state files (if the virtual machine is suspended), settings files, and logs. For more information, see Contents of the virtual machine bundle in Fusion (1021016).

However, if the size of your virtual disks is significantly larger than the used space shown in the virtual machine's Operating System, it is possible to reduce this size.

To reduce the size of the disk, you must defragment the disk within Windows, shrink the virtual disk using VMware Tools, and then clean up the virtual disk from within Mac OS using the built-in Fusion utility.

Notes:

  • This process does not apply to pre-allocated disks. To make a pre-allocated disk sparse, see Making a Fusion virtual disk pre-allocated or sparse (1021565).
  • You cannot perform a Clean up or Clean up option would not be available for an Encrypted VM. You must Decrypt the VM to perform a Clean up
     

    To determine if your disk is sparse or pre-allocated, check the virtual disk settings:

    1. Launch Fusion.
    2. From the menu bar, go to Virtual Machine > Settings.
    3. Click Hard Disk section.
    4. Under Advanced, look for the Pre-allocated check box.

      If Pre-allocated is selected, then your virtual disk is pre-allocated. If Pre-allocated is not selected, your virtual disk is sparse.
       
  • If your disk has snapshots, you need to delete the snapshots before trying to reduce the size of the disk. For more information, see Deleting snapshots in VMware Fusion (1020245).

Defragmenting within Windows

In a Windows virtual machine, you must first run a disk defragment from within Windows. Defragmenting within Windows ensures that all of the used spaces are contiguous. You can then reduce the size of the virtual disk.

To run a disk defragment within Windows, follow the instructions from Microsoft:

Note: The preceding links were correct as of September 9, 2013. If you find that a link is broken, provide feedback and a VMware employee will update the link.

Shrinking the virtual disk

After defragmenting the virtual disk, use VMware Tools to erase empty disk sectors at the end of the disk, so that and the space is freed up.

Note: In Fusion 5.x and above, shrinking is automatically done while Cleaning up the disk. Therefore, this option is removed from VMware Tools Panel.

To shrink the virtual disk in VMware Fusion 4.x and earlier:

  1. Open the VMware Tools Control Panel / Toolbox:
     
    • In Windows: Double click the VMware Tools icon in the system tray, or go to Start > Control Panel > VMware Tools.
    • In Linux:
       
      1. Open a command prompt. For more information, see Opening a command or shell prompt (1003892).
      2. Run this command:

        vmware-toolbox
         
  2. Click the Shrink tab.
  3. Ensure that your boot drive is selected.
  4. Click Prepare to Shrink and then follow the prompts.

    Caution: Do not shutdown your virtual machine or the Mac while the disk is shrinking. Do not try to cancel the process. Interrupting this process can cause irreparable damage to your virtual disk and you may not be able to start your virtual machine again.

Cleaning up the disk

After shrinking your virtual disk, Fusion ensures that the virtual disk is optimized for Mac OS X. Mac OS X does this automatically for smaller files. However, virtual machine files are too large and you must manually clean up the disk.

To clean up your virtual disk:

In Fusion 4.x and above:

  1. Shut down your virtual machine.
  2. Go to Virtual Machine > Settings > General.
  3. Select Clean Up Virtual Machine.
Note: For Fusion 10.x, To enable auto clean up check the box for " Clean up disks after shutting down the virtual machine “.

In Fusion 3.x and earlier:
  1. Shut down your virtual machine.
  2. Go to Virtual Machine > Settings > Hard Disks.
  3. Select Clean Up Disk.

Additional Information

For translated versions of this article, see: