Subject: Re: bug#21522: assertion metadata_length > 0 in add_logical_part_metadata failed

From: "Brian C. Lane" <[email-masked]>
Date: Thu, 24 Sep 2015 10:45:00 -0700

On Thu, Sep 24, 2015 at 01:21:50PM -0400, Phil Susi wrote:
> On 9/24/2015 11:56 AM, Brian C. Lane wrote:
> > 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 suppose it is
> > possible that would work since it has separate pointers for the
> > partition and the next EBR but none of the authoritative diagrams I've
> > seen show that. eg.
> > https://technet.microsoft.com/en-us/library/cc977219.aspx also shows the
> > EBR at the start of the logical partition.
> 
> Yes, it should work anywhere, and it seems that both the linux kernel
> partition table parser and fdisk are fine with it.  I'm pretty sure that
> DOS was also fine with such an arrangement, though anyone sane has
> always put it just before the logical partition like all of the diagrams
> show.  What I wonder is why has this not been an issue before, and why
> is it one now?  That is, since it seems no partitioning tools have ever
> done this before, which one is doing it now?

I've only seen 1 other bug like this in Fedora, and I basically told
them they need to recreate their disk or use some other tool. I'm not
sure we need to support such a corner case.

> 
> 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?

The EBR code really needs more comments I think :) What's happening is
it is rewriting the extended partition and each of the logical
partitions in a loop. Note that below that code it calls itself
passing in the new part. So it will run out to the last logical
partition and then start writing tables, so you have to hold things
upside down and backwards to understand it :)

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)