Defrag in Windows VM?

Storage folks refer to VMs as I/O blenders. This is because all of the guest's files are typically inside of a "container" like a VMDK. This VMDK is a single file that contains all other files used by the VM.

Consider that an 80GB VMDK might not have all block allocated sequentially on the disk - this is even more likely if you're using thin provisioning. By running a defrag inside of the VM, you're not actually making the files sequential on the physical disk, you're making them sequential inside of the container and that container is likely not sequential on the physical disk. Basically, in a lot of cases it's a waste of time and performance gains are very minimal at best.


If you allocated all disk space on creation and defragment that file on your real disk and then defragment the virtual disk then I expect to see a small advantage.

@MDMarra's explained perfectly why it makes no sense to just defragment the virtual disk. No way to improve that.


As a real answer, I've never seen much impact from defragging virtual machines. That being said, if you are going to potentially shrink the drive at some point, you would want to defrag to help with that process.


If defragmenting is your goal, here's what you can do:

  1. Shutdown your guest OS. Proper Shutdown, not Suspend

  2. In the VM Ware Player Window click on the Guest OS once and click on "Edit Virtual Machine"

  3. In "Hardware" tab click on "Hard disk". On the right side you will see a button named "Utilities". Clicking it will give you a drop-down menu. Select "defragment".

I have a Ubuntu 12.04 Guest OS and I must say, I did not see any performance difference after defragmenting.