Bug 634649 - [RFE] Write a tool to align the partition(s) in a Windows XP image to a multiple of 8 sectors
Summary: [RFE] Write a tool to align the partition(s) in a Windows XP image to a multi...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard: pm_inlist
Depends On:
Blocks: 741183 747667
TreeView+ depends on / blocked
 
Reported: 2010-09-16 15:52 UTC by Yaniv Kaul
Modified: 2013-07-04 02:07 UTC (History)
12 users (show)

Fixed In Version:
Clone Of:
: 741183 (view as bug list)
Environment:
Last Closed: 2011-12-06 08:53:46 UTC
Embargoed:


Attachments (Terms of Use)

Description Yaniv Kaul 2010-09-16 15:52:17 UTC
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:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Richard W.M. Jones 2010-09-17 10:03:33 UTC
Mike Snitzer wrote these documents on the issue:

http://people.redhat.com/msnitzer/docs/io-limits.txt
http://people.redhat.com/msnitzer/snitzer_rhsummit_2009.pdf

Comment 2 Richard W.M. Jones 2010-09-17 11:20:04 UTC
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
  run
  part-init /dev/sda mbr
  part-add /dev/sda primary 64 -64
  EOF

(references:
http://libguestfs.org/guestfish.1.html
http://libguestfs.org/guestfish.1.html#part_init
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 11:21:39 UTC
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 08:30:22 UTC
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 15:18:35 UTC
Make this bug public.

Comment 10 Richard W.M. Jones 2011-05-10 14:41:38 UTC
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 10:26:03 UTC
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 16:05:45 UTC
See also
https://bugzilla.redhat.com/show_bug.cgi?id=743276

I've also written an alignment scanning tool:
http://libguestfs.org/virt-alignment-scan.1.html

Comment 14 Richard W.M. Jones 2011-10-20 21:13:01 UTC
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 08:53:46 UTC
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.