[Parted-maintainers] Bug#579948: Some debugging info

Jurij Smakov jurij at wooyd.org
Mon Jun 7 14:41:34 UTC 2010


By now I'm pretty sure that this problem is due to the alignment code. 
It goes like this:

1. ped_disk_add_partition() is called to add the partition. The 
constraint which is passed to it is computed in  
ped_device_get_optimum_alignment():

/* Align to a grain of 1MiB (like vista / win7) */
align = ped_alignment_new(0, 1048576 / dev->sector_size);

As dev->sector_size is 512, we end up with alignment of offset 0 and 
grain_size 2048, and the resulting constraint passed to 
ped_disk_add_partition() has start_align set to {offset = 0; 
grain_size=2048} and end_align set to {offset = 2047, grain_size = 
2048). That looks normal.

2. _partition_align() is called to align the partition with this 
constraint. This simply calls the disk-specific partition_align 
function, in this case sun_partition_align().

3. In sun_partition_align: disk_specific->cylinder_alignment is set to 
1, so the final alignment will be an intersection of our initial 
constraint and _get_strict_constraint(part->disk).

4. In _get_strict_constraint() the alignment is determined by a 
product of dev->bios_geom.sectors and dev->bios_geom.heads. In my case 
the former is 63 and the latter is 255, so the resulting strict 
alignment will enforce partition alignment to 63 * 255 = 16065 
sectors. 

5. An intersection of two constraints, one aligning to 2048 and 
another aligning to 16065 sectors, is computed. The least common 
multiple of those two happens to be their product, so a combined 
constraint ends up to be forcing the alignment to 2048 * 16065 = 
32901120 sectors, or 16.8G (!). Looking at the debugging dump, the 
second partition during my install was placed at 16845373440, which is 
exactly 2048 * 16065 * 512, which confirms the alignment issue.

I have no idea how it worked before, nor could I figure out why the 
addition of first partition worked as expected.

Best regards,
-- 
Jurij Smakov                                           jurij at wooyd.org
Key: http://www.wooyd.org/pgpkey/                      KeyID: C99E03CC





More information about the Parted-maintainers mailing list