Page 1 of 1

Fragementation on Host

Posted: 2. Dec 2010, 21:18
by oraclelinuxuser
Hi,

Has anyone experience excess fragmentation on host systems having large guests? I am using Windows XP running a 50 G Oralce Linux guest. The guest has a lot of software on it, and I've created about 5 snapshots. What I am finding is that I have to use the defrag utility on the Host sometimes twice a month. I know it is time to do the defrag because I start getting lots of BSODs.

I don't know if there is a connection between my file fragementation issues on the host and my guests. Does anyone have similiar issues?

Thanks,
Dan

Re: Fragementation on Host

Posted: 3. Dec 2010, 11:10
by mpack
It depends how you are using the guests. VDI files themselves (like any other file type in fact) can only become fragmented as they grow. Normally the growth of a new dynamic VDI will soon tail off - unfortunately snapshots by their nature mean that each new snapshot starts a new growth spurt (add this to the list of reasons why snapshots should be avoided). However this behaviour should not lead to fragmentation of other host files unless the drive is heavily congested - in which case everything leads to fragmentation.

You can also cause fragmentation for other files on the host (not only the VDI files themselves) by using large fixed (rather than dynamic) sized VDIs. This is basically just a repetition of the "heavily congested" point I already made.

Light fragmentation, e.g. inside a non-snapshot VDI whose growth has largely tailed off, can be cured by periodically running a defrag tool.

Re: Fragementation on Host

Posted: 7. Dec 2010, 23:41
by mcklaw
Hi! What should be the correct defrag order (Windows SOs)?
* First defrag guests and next defrag host?
* First defrag host and next defrag guests?
* none of above? :D

BTW, thanks mpack for your great tool!

Re: Fragementation on Host

Posted: 8. Dec 2010, 13:01
by mpack
mcklaw wrote:Hi! What should be the correct defrag order (Windows SOs)?
I can't think of any reason for the order to matter. But it isn't only host and guest filesystem fragmentation that needs to be considered, the internal block ordering in a dynamic VDI can also be fragmented.

The following instructions assumes that the reader has not used snapshots. If you have used snapshots then optimization is still possible, but you'd better be an expert, and it's beyond the scope of what I intend to discuss here.

Ok, To get best performance from a VDI you should :-
  • Clone the VDI using my CloneVDI tool, with "Keep UUID" selected and every other option switched off (actually you can leave "compact" on if you want). This creates a simple clone of the original VDI with the image blocks now sorted into linear order and with other performance tweaks (blocks aligned on 4k boundary). This step must come first since of course it replaces the old VDI file. Keeping the UUID should make this clone a "drop in replacement" for the old VDI.
  • Defragment the host. In fact on Windows hosts I believe there's a free tool called "contig" which can defragment a single file, which should be faster - if that matters to you.
  • Mount the cloned VDI in the guest, boot it up, and defrag the guest filesystem. This time it must be complete, you can't use contig.
Obviously, most of the above is wasted effort if the dynamic VDI size hasn't stabilized yet.