[parted-devel] libparted ped_disk_get_max_partition_geometry() function oddness

ben scott benscott at nwlink.com
Sun Feb 15 00:59:51 UTC 2009

hope this is not to far off topic for this list. I tried the #parted
IRC already and received no reply.

I am writing a program that uses libparted to create and move
partitions and have run into a problem I can't figure out. Lets say I
create three partitions on an MS-DOS disk label with libparted and
then I want to move the middle one. My program calls
ped_disk_get_max_partition_geometry() to find out how much space is
available. The problem is that the geometry returned is less than the
real space available, often off by many megabytes. If I create the
original partitions with fdisk or some other program the function call
returns the correct value, even when I create the partitions at the
*exact* same spot. When I looked at the partition table I noticed that
there is one diffence I can see. The LBA addresses are the same but
the CHS ones are different.

As an example linux fdisk reports for a disk:

   226 heads, 63 sectors/track, 10977 cylinders, total 156301488 sectors

and creates this partition:

   start: 63 end: 303407
   0000447 01 01 00 83 45 3f 15 3f 00 00 00 f1 a0 04 00 00 00

While my program creates this partition:

   0000447 01 01 00 83 e1 3f 12 3f 00 00 00 f1 a0 04 00 00 00

Partitions created with gparted seem to work fine too yet it uses
libparted. Does anyone know what I am doing wrong?

Thank you.

More information about the parted-devel mailing list