Answer the question
In order to leave comments, you need to log in
Defragmenting a virtual machine disk?
Does it make sense to defragment the HDD using the guest OS?
As I understand it, the guest OS does not have access to real disk sectors, so the defragmentation program will not be able to optimally overwrite its own data.
If I'm wrong, please explain where exactly.
PS Small discussion in G+ - plus.google.com/u/0/109470169824353610901/posts/FN...
Answer the question
In order to leave comments, you need to log in
As usual, depending on what and how.
LVM and, moreover, the physical partition is only a guest one and can defragment. Fragmentation of LVM in pieces of 4MB will not solve anything.
If the VM lives on a file:
defragmentation must be performed on both the host and the virtual machine.
Because fragmentation can be terrible (numbers are random):
a file is requested. The guest sees that he is in LBA 5723-5730, 8765-8800 and asks for these sectors. The host sees the request, translates the file fragmentation, and requests will go from the real disk to get the initial 5723-5728 from one disk area, 5729-5730 from the other, 8765-8780 from the third and 8780-8800 from the fourth.
So, if we defragment the host FS, we get 2 disk positionings instead of 4, if only the guest FS - how lucky (because the guest addressing really has nothing to do with the host FS), if both at once, then we get 1 operation.
If we take as an example the same guest system, but a defragmented host system (which is not uncommon when using a fixed-size image file that is put and not touched once), then, in addition to some overhead for servicing the file itself in the host FS and a bunch of different caches, we get a transparent translation of guest addresses into physical disk addresses and a direct impact of guest FS fragmentation on disk operation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question