Subject: bug#21560: bug-parted Digest, Vol 154, Issue 8

From: Rod Smith <[email-masked]>
Date: Fri, 25 Sep 2015 13:01:45 -0400

On 9/24/2015 11:56 AM, Brian C. Lane wrote:
>>
>> While parted lays out the disk this way, it doesn't have to be.  The EBR
>> for each chained logical volume can be placed anywhere in the extended
>> partition.  In his case, it looks like both are at the start of the
>> extended partition.  This is perfectly ok and parted should accept it.
>> 
>> Now that I have both EBRs I'm able to reproduce the crash and will try
>> to fix it.
> 
> Are you sure? According to
> https://en.wikipedia.org/wiki/Extended_boot_record the EBR is at the
> start of each logical partition, and chains to the next.

I've seen this type of layout before. I don't know of anything that will
create it if given the choice, but I'm pretty sure that sfdisk will
create such a layout if it's forced to do so. You might try using sfdisk
to create a series of logical partitions with no gaps between them but a
big gap between the start of the extended partition and the first
logical partition to reproduce this behavior.

On hu, 24 Sep 2015 12:33:08, James Ring wrote:

> I wish I could remember exactly how I partitioned the disk. I think I
> resized the NTFS partition using the Windows 7 tools and then let the
> Ubuntu installer partition the rest of the disk.

I wouldn't trust the Windows partitioning tools as far as I could throw
them if they were written to a CD-R made of solid neutronium. I've seen
too many tales over the years of them doing weird things with
partitions, and especially with extended and logical partitions. I
recall a rash of problem reports a few years ago in which the Windows XP
(IIRC) installer was converting a logical partition into a primary
partition but leaving it inside the extended partition. In other words,
it's entirely believable that the Windows tools set things up this way
-- but I certainly don't know that for a fact. Using sfdisk is likely to
be an easier way to reproduce the issue.

> From: Phil Susi <[email-masked]>
> 
> I've also been looking at the parted code for writing the partition
> table and I'm beating my head against the desk now because I swear, it
> can't possibly work the way it is.  What am I missing here?
> 
> It *should* be writing the EBR for the next logical partition to start -
> 1, or prev->end + 1.  Instead, it does this:
> 
> geom = ped_geometry_new (disk->dev, part->prev->geom.start,
>                          part->geom.end - part->prev->geom.start + 1);
> 
> That says put it in the boot sector of the previous logical partition,
> doesn't it?

I've only looked at this briefly, but this line looks like it might be
something to do with manipulating the extended partition rather than a
logical partition. If part is the logical partition being created and if
part->prev is the extended partition, then this would be passing
ped_geometry_new() the start point of the extended partition and the
required size of the extended partition to hold the logical partition
being created.

Brian's quite right that this code needs more comments; it's clear as mud.

-- 
Rod Smith
[email-masked]
http://www.rodsbooks.com