[parted-devel] The new alignment options
Phillip Susi
psusi at cfl.rr.com
Thu Jan 5 21:38:16 UTC 2012
It looks like the new optimal/minimal alignment options were implemented
half in libparted and half in parted. libparted provides the
ped_device_get_optimium_alignment(), but it is parted's do_mkpart() that
attempts to enforce it.
Contrast this with the way that cylinder alignment used to work. It was
implemented by having parted set the PED_DISK_CYLINDER_ALIGNMENT flag,
and that caused the disklabel to enforce the alignment requirement. It
seems to me that the new alignment modes should have been added in an
orthogonal way; by adding new PED_DISK_XXX_ALIGNMENT flags and letting
the disklabel enforce it. Also the synthesized free space partitions
should be subjected to the same constraints.
There are a few issues that involve the shown free space being
misleading that I think would be fixed by this change. When using the
old cylinder alignment, print would show the free space starting at
sector 63, even though you technically could create a partition starting
at sector 1. When using optimal alignment, print still shows free space
starting at sector 63, even though you get an alignment exception if you
try to start a partition there. Not only is this confusing to a user,
but to scripts as well.
For example, I am aware of a bug involving a script uses parted to
automatically create a single partition in an image file. Parted
advertises via print free that space from 16.5kb onward is free, so the
script creates a partition starting at 16.5kb. This creates an
improperly aligned partition, and prevents the installation of grub. If
the script requested optimal alignment, then parted should not advertise
misaligned spaces.
Finally, if you are using optimal alignment, the free space lists small
bits at the start and end of the disk that aren't usable without
breaking alignment. This is especially frustrating for gparted users
who see the extra space at the end of the disk and keep wanting to drag
the partition to the right to use it, and it mysteriously won't work.
When using cylinder alignment, the advertized free space is cylinder
aligned, so you don't see the sub-cylinder gaps, even though they are
there, so I think that optimal mode should behave the same way.
On IRC Jim was concerned that this change would negatively impact other
libparted users, but it would only make a difference if they choose to
set the PED_DISK_XXX_ALIGNMENT flag, so it would be a backward
compatible change.
I would like to hear any additional thoughts that anyone has.
More information about the parted-devel
mailing list