Take the 2-minute tour ×

I've read conflicting advice on this issue so thought I'd ask here.

Should I be running a scheduled defrag within my VM?

share|improve this question
If you got vmware workstation, you can actually defrag the VM disk itself. –  lbanz Oct 19 '12 at 12:56

5 Answers 5

up vote 28 down vote accepted

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.

share|improve this answer
Thanks, I'm primarily interested in the performance aspect. –  SteB Oct 19 '12 at 13:04
@SteB ...that's exactly what my answer is about. The increase in performance is directly related to being able to perform sequential reads/writes instead of random reads/writes on the physical disk. If the container is fragmented, then you're not really doing anything useful to the files inside of that container. –  MDMarra Oct 19 '12 at 13:07
If you're going to compact a dynamic VMDK (or any other virtual HD file) you generally have to defrag it first to get correct results. Other than that, no reason to run defrag ever, the performance gain is completely negligible. –  Chris S Oct 19 '12 at 13:11
Is it theoretically possible for a guest's HD to be "fragmented" (as the VM sees it) badly enough for split I/O to become a problem inside the VM? That would be one of very few use cases I can think of for defragmenting inside a VM. I'm not sure how a VM would get to that state while still being otherwise useful though. –  afrazier Oct 19 '12 at 14:00
@afrazier Sorry, I don't understand what you mean. The performance won't be any worse than a physical disk that's fragmented. –  MDMarra Oct 19 '12 at 14:15

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
Ubuntu uses ext4 by default, which does not normally fragment, so there is no need to de-frag ext3/4, and you won't aim any advantage if you do, in physical or virty –  Rqomey Oct 25 '12 at 20:30

Even though the Windows XP is on VMWare Player, the maintenance of that OS should be carried out the same for best performance.

Even if you have defragmented the VM HD you will also have to make sure that the VHD file is defragmented fully on the host OS otherwise this will not have the best effect.

share|improve this answer
This is wrong; read the other answers to find out why. –  HopelessN00b Oct 19 '12 at 20:30

Your Answer


