Defragmenting, shrinking, and cleaning up Fusion virtual machine disks (1001934)
You may be able to reduce the size of a 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 is 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 hasn't actually been 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.
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.
- This process does not apply to pre-allocated disks. To make a pre-allocated disk sparse, see Converting a virtual disk to pre-allocated (1021565).
To determine if your disk is sparse or pre-allocated, check the virtual disk settings:
- Launch Fusion
- From the menu bar, go to Virtual Machine > Settings.
- Click Hard Disk section.
- 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:
- Windows XP: How to Defragment Your Disk Drive Volumes in Windows XP
- Windows Vista: Improve performance by defragmenting your hard disk
- Windows 7: Improve performance by defragmenting your hard disk
Note: The preceding links were correct as of May 28, 2011. 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, 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:
- 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:
- Open a command prompt. For more information, see Opening a command or shell prompt (1003892).
- Run this command:
- Click the Shrink tab.
- Ensure that your boot drive is selected.
- 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.
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 5.x:
- Shut down your virtual machine.
- Go to Virtual Machine > Settings > General.
- Select Clean Up Virtual Machine.
- Shut down your virtual machine.
- Go to Virtual Machine > Settings > Hard Disks.
- Select Clean Up Disk.