Fix structure sorting and partition numbering
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ubuntu Image |
Fix Released
|
Critical
|
Barry Warsaw |
Bug Description
In LP: #1631423 we changed the way structures are sorted, which had a side-effect of changing the partition numbering scheme. Structures were sorted by disk offset (implicit or explicit) and the associated partitions (for all but the special 'mbr' type, which doesn't get a partition) are numbered by the sort order.
This breaks certain existing use cases where the partition numbering needs to be explicitly described. Specifically, some device firmwares look for the bootloader at a specific partition number, but that partition may be at a non-zero offset, with partitions having higher numbers placed earlier in the disk image.
The gadget.yaml spec does not support explicit partition numbering so we need to implicitly number partitions according to the order in which the structures appear in the gadget.yaml. The sorting by offset breaks this.
However we still need to sort by offset in order to do the no-overlap sanity check. We need to continue to verify that none of the structure definitions cause partitions to overlap. It's just that we should not expose this structure sorting to the disk image building code that applies the partition numbering. This should re-establish the behavior where partition numbers are assigned based on the order in which the structures appear in the gadget.yaml.
Changed in ubuntu-image: | |
status: | In Progress → Fix Committed |
Changed in ubuntu-image: | |
status: | Fix Committed → Fix Released |
One other complication; we currently calculate the rootfs offset based on the disk-offset sorted order of the gadget.yaml named partitions. It lives just after the farthest out (which previously equaled the last) partition.
Now, because the farthest out won't necessarily be the last named partition, we have to still ensure that the rootfs gets written after the farthest out partition, *not* the last named partition.