7

I am using VMplayer on Windows 7 and 2008 R2. Inside the guest OS, in VMware tools, there is a "Prepare to shrink" option on the "Shrink" tab. In the host VMplayer menu there is "Defragment" and "Compact" options (available when the VM is shut down). VMplayer documentation says you should also defragment using an OS based defragment tool within the guest and outside the VM in the host. That leaves five operations:

  1. defragment within the VM using OS defragmenter.
  2. shrink within the VM using VMtools
  3. defragment outside the VM in the host using OS defragmenter
  4. defragment in the host using VMplayer settings menu.
  5. compact in the host using VMplayer settings menu.

My question is this. Which of these operations are required and in exactly what order should they be performed?

fupsduck
  • 173
  • 1
  • 1
  • 5
  • If you plan to compress the compacted vm into archive then [disk zeroing](https://serverfault.com/questions/165070/how-to-zero-fill-a-virtual-disks-free-space-on-windows-for-better-compression) would increase compression ratio. – Vadzim Jan 18 '19 at 21:21

2 Answers2

7

First, please realize you don't have to do this maintenance very frequently. If you want to go through the full list, here's the order and rationale.

  1. Defragment within the VM (if the machine is thin-provisioned, defragmenting later will expand the .vmdk as blocks are moved)
  2. Shrink the disks within the VM (this writes zeroes to unused sectors so the host can recognize which blocks are unused). This will temporarily increase the VMDK size to the configured size of the virtual disk. Then power off the VM.
  3. Defragment the disks from within VMware Player. This will move the blocks in the VMDK from their chaotic state (due to growth/use) and order them by actual block number.
  4. Compact the disks from within VMware Player. Since the empty blocks are zeroed, VMware can remove those blocks from the VMDK and reclaim space on the host.
  5. Defragment the host system to reorder all host files (including the VMDK) and remove fragments.
Jeff McJunkin
  • 1,342
  • 1
  • 8
  • 16
  • Somehow it is not working for me. I'm using VMware Player 6.0.1 and have Windows 7 virtual machine. While guest OS reports 5GB of 20GB free the size of virtual hard drive is still 20GB in host OS even after all steps above. What could it be? – Mikhail Dec 25 '13 at 11:21
5

On newer versions of VMWare Player, this should work:

VMTools ui don't exist so do the shrink in an (elevated) cmd prompt:

cd "C:\Program Files\VMWare\VMTools"
VMwareToolboxCmd.exe disk shrink c:\
fuero
  • 9,413
  • 1
  • 35
  • 40