Bug 634649 - [RFE] Write a tool to align the partition(s) in a Windows XP image to a multiple of 8 sectors
[RFE] Write a tool to align the partition(s) in a Windows XP image to a multi...
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Richard W.M. Jones
: Improvement
Depends On:
Blocks: 741183 747667
  Show dependency treegraph
Reported: 2010-09-16 11:52 EDT by Yaniv Kaul
Modified: 2013-07-03 22:07 EDT (History)
12 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
: 741183 (view as bug list)
Last Closed: 2011-12-06 03:53:46 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Yaniv Kaul 2010-09-16 11:52:17 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):

How reproducible:

Steps to Reproduce:
Actual results:

Expected results:

Additional info:
Comment 1 Richard W.M. Jones 2010-09-17 06:03:33 EDT
Mike Snitzer wrote these documents on the issue:

Comment 2 Richard W.M. Jones 2010-09-17 07:20:04 EDT
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

http://libguestfs.org/guestfish.1.html#part_add )

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?
Comment 3 Richard W.M. Jones 2010-09-17 07:21:39 EDT
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.
Comment 6 Richard W.M. Jones 2010-09-20 04:30:22 EDT
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
Comment 9 Richard W.M. Jones 2010-10-14 11:18:35 EDT
Make this bug public.
Comment 10 Richard W.M. Jones 2011-05-10 10:41:38 EDT
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
Comment 11 Jim Meyering 2011-09-13 06:26:03 EDT
Hi Rich,

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.
Comment 12 Richard W.M. Jones 2011-10-05 12:05:45 EDT
See also

I've also written an alignment scanning tool:
Comment 14 Richard W.M. Jones 2011-10-20 17:13:01 EDT
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:

 --align-first auto|never|always
    lets you adjust whether the first partition is aligned
    (default: auto)

 --alignment N
    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.
Comment 15 Richard W.M. Jones 2011-12-06 03:53:46 EST
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.

Note You need to log in before you can comment on or make changes to this bug.