Is It Necessary To Defrag Virtual Machines?

bekdik

Honorary Master
Joined
Dec 5, 2004
Messages
12,860
Will defragging of Virtual Machines improve their performance? What about defragging the Host machine?
 

Johnfpro

Senior Member
Joined
Jun 6, 2009
Messages
537
The general consensus on the web is yes. Google "Virtual machine defrag" and you'll find some articles on this.
 

davemc

Executive Member
Joined
Apr 8, 2009
Messages
6,518
Accessing the bits of a fragmented file from the specific disk format of the operating system within the operating system who's specific disk format is probably inherently different.
Wait, what?

Actually ... put each of the VM disk files on their own partitions (one per partition) on the host drives and you should never have to defrag them, because they're not sharing space with other files as they grow, or you could simply force them to pre-reserve all the space assigned to them, and then defrag that reserved space once. If the drive files on the host do not change size, they will remain defragmented.

But you will have to defrag the actual drive system inside the VM now and then if fragmentation starts causing excessive disk io's. The trick is to know when it's actually causing a problem.
 
Last edited:

Electromag

Active Member
Joined
Apr 24, 2010
Messages
87
Which hypervisor are you using?

But yes, I am using VmWare Workstation on top of Windows with my VMs on their own drive. there isnt much happening file wise on that drive so no defragging has been needed there for a while but defragging does need to get done within the VMs themselves. And yes, I have definitely seen performance improvement over when the VM files on the disk were fragmented versus once I had the disk organised and defragged.
 

bekdik

Honorary Master
Joined
Dec 5, 2004
Messages
12,860
I have definitely seen performance improvement over when the VM files on the disk were fragmented versus once I had the disk organised and defragged.

Are you refering to the host's drives or the virtual drives inside the vm?
 
K

kingrob

Guest
A VM is loaded into RAM, so maybe you would like to defrag your system RAM?? Or just switch your VM off, then switch it on again. :p
 
Last edited by a moderator:
K

kingrob

Guest
bekdik, I SERIOUSLY hope you just started this thread as a joke. Right?
 

Electromag

Active Member
Joined
Apr 24, 2010
Messages
87
Are you refering to the host's drives or the virtual drives inside the vm?
Ok, maybe I wasn't that clear. The VMs that I run have apps installed that do a lot of Disk I/O. So the performance gains I have seen have not only been at boot up (much faster once defragged) but also in run time as the apps are doing read/writes to the disk.
 

The_Unbeliever

Honorary Master
Joined
Apr 19, 2005
Messages
103,196
Nah, just delete the VM when it need defragging and restore from a backup VM. :p

Having said that, I got two VM's which runs 24x7, gotta put a scheduled defrag on them.
 

Conradl

Expert Member
Joined
Dec 10, 2008
Messages
2,629
First question is, as mentioned above, what software are you using? And what types of VM disks?

Host Defrag - If you are using a type 2 hypervisor and assign all the disk space to the virtual disk, then it cannot fragment and therefore does not need to be defrag'd (as with any large file created on continuous disk space). If your disk has been set to grow, then the performance is probably lousy in the first place, and defrag will not speed things up much. In fact, defraging the VM allows the disk to shrink, which will result in a performance decrease when the disk is forced to grow again. A type 1 VM also cannot fragment so there is no need to defrag here.

Guest - Defrag only improves performance in very, very few instances. It is very simple to prove and quantify. The virtual guests would benefit the same as a physical machine would from defrag; again mostly it will not improve performance. Be careful if you are using snaps, or shared storage. Defrag is very IO intensive and will reduce performance on shared storage. It will also make the snaps grow....

In short, the benefits of defrag are 99% myth, the "proof" of the benefits created in a lab under ideal conditions. Defrag is a total waste of time....
 

davemc

Executive Member
Joined
Apr 8, 2009
Messages
6,518
No, what he said was, defrag is a waste of time 99% of the time.
If you are in that 1% margin ... it's most certainly not a waste of time.
As I said, the trick is to know when your disk IO's (especially seek's) are excessive because of fragmentation.
 
Top