Red Hat Bugzilla – Bug 634649
[RFE] Write a tool to align the partition(s) in a Windows XP image to a multiple of 8 sectors
Last modified: 2013-07-03 22:07:41 EDT
Description of problem:
According to multiple sources (http://media.netapp.com/documents/tr-3747.pdf for example) alignment can have huge impact on performance. Our qcow2 is indeed aligned to 64K boundaries, but then XP goes and install itself on sector 63, which means 31.5K into the first qcow2 cluster. That's not that great.
See the above NetApp PDF, section 4.4.1 and on, how this can easily be fixed pre-installation. libguestfs should do it via its NFS utilities.
This can be later utilized by RHEVM.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Mike Snitzer wrote these documents on the issue:
Yaniv, there are two issues here: getting the alignment right
in the first place, and fixing alignment issues in existing
operating system images.
Getting the alignment right for Windows < 2008: The document
in comment 0 (section 4.4.1) has an incredibly complex method
by which one can fix Windows XP so it installs itself in
properly aligned partitions. AFAIK you can do the same thing
using libguestfs (and a bit simpler) by partitioning the disk
manually beforehand, eg:
guestfish -a /dev/VG/WinXP <<EOF
part-init /dev/sda mbr
part-add /dev/sda primary 64 -64
I'm actually going to test whether this works today!
The second issue is reporting on and fixing alignment issues
in existing guests. ie. You've already got some Win XP
guests, you don't want to reinstall them, how can you fix
them? For this I envisage some sort of 'virt-align' tool
which would report and fix alignment issues, eg:
virt-align --report /dev/VG/WinXP
*** partition 1 is not aligned!
virt-align --fix /dev/VG/WinXP
*** realigning partition 1 to 4K alignment ...
There is some overlap with virt-resize, since virt-resize
(as a side-effect) always aligns partitions to 64 KB.
However virt-resize is quite a complex tool and does not
do in-place resizing, so it's probably not suitable for
this simpler job.
(reference: http://libguestfs.org/virt-resize.1.html )
How does this all sound to you?
I forgot to add: It seems like the host LVs themselves will
already be aligned correctly, so this is not something we
have to worry about.
BTW I tried to install Windows XP, but apparently we don't
support it or it no longer works under KVM. Seems to be
related to this problem: https://bugs.launchpad.net/qemu/+bug/586175
Make this bug public.
Just looking over this again.
What's actionable here?
It appears to me that the only guests which really have alignment
problems are Windows XP guests. (If I'm wrong about this, *please*
point it out).
Now given that, here are possible actions:
- a tool that fixes Windows XP guests, if that is possible
- a tool that somehow fixes the Windows XP install process
(see documents in comment 1)
- a tool that warns you if your guests are badly aligned, but
otherwise does nothing
- do nothing because Windows XP is old and slow and on the way out
I suspect that XP is still important enough that we should not ignore it.
In any case, warning about a poorly aligned guest sounds like a worthwhile feature, if only to forestall bug reports about poor performance.
I've also written an alignment scanning tool:
virt-resize >= 1.13.23 can now align ALL partitions
in any Windows guest, and partition >= 2 in Linux guests.
There are two new flags:
lets you adjust whether the first partition is aligned
lets you select the default alignment of partitions
in sectors (default: 128 sectors)
I tested this on Windows XP, Windows 7, and various Linux guests.
virt-alignment-scan (in libguestfs 1.14) can scan for
misaligned guests. virt-resize (also in 1.14) can fix
alignment. Therefore this is fixed as far as libguestfs
is concerned, so I'm closing this bug.