[parted-devel] keeping partitions in disk order
David Cantrell
dcantrell at redhat.com
Mon Aug 28 14:12:27 UTC 2006
Andrew Gaffney wrote:
> Andrew Gaffney wrote:
>> Andrew Gaffney wrote:
>>> leslie.polzer at gmx.net wrote:
>>>> Sorry for letting you both wait so long. A lot of things have
>>>> backlogged during my absence in August and full-time work in July.
>>>>
>>>> Try calling ped_disk_enumerate_partitions() after the operation
>>>> and see whether it does what you want.
>>>
>>> What exactly does this function do? There doesn't appear to be a
>>> wrapper function in pyparted for it, which means that I can't really
>>> test it. If it does do exactly what I want, I'll try requesting its
>>> addition with pyparted upstream :)
>>
>> Looking at the parted code, this function is currently only called at
>> the end of ped_disk_remove_partition(), so it stands to reason that
>> it's designed to "fill in holes" in the numbering scheme when a
>> partition is removed. Will this function also work as-is to rearrange
>> the partition numbers so that they match physical disk order? From
>> what I can understand of ped_disk_enumerate_partitions() and
>> _partition_enumerate(), it does not seem so. Please correct me if I'm
>> wrong :P
>
> I traced the code down even farther to msdos_partition_enumerate() in
> libparted/labels/dos.c. I found the following code:
>
> /* don't re-number a primary partition */
> if (part->num != -1 && part->num <= 4)
> return 1;
>
> Looking around, I found something similar in sun_partition_enumerate()
> in libparted/labels/sun.c:
>
> /* never change the partition numbers */
> if (part->num != -1)
> return 1;
>
> Anyone know why these are here?
On DOS systems, you run the risk of preventing other operating systems
that may be on the disk from booting.
On Sun systems, it shouldn't really matter about partition numbers, you
just want to make sure you avoid using the 4th number as that represents
the entire disk on the BSD disklabel (or should, it's up to the software
to ensure that). The BSD disklabel also traditionally uses specific
slices for things like /, /usr, and swap. Unless there's a really good
reason, it's best to adhere to those to maintain maximum compatibility.
--
David Cantrell
Red Hat / Westford, MA
More information about the parted-devel
mailing list