-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix logical partitions renumbering #2118
Conversation
The renumber_logical_partition function does not do the right thing if called after removing a primary partition. As it is today, the implementation does not ensure that the new partition numbers are in the range of logical partition numbers. As a consequence, if we remove partition 1 from a MSDOS partition table, the logical partitions will be renumbered 2, 3, 4, ... which are not in the 5+ range. The new numbers might also conflict with primary partition 2, 3, and 4 if they exist. Fixed by invoking the function only after removing a logical partition. Signed-off-by: Olivier Gayot <[email protected]>
@ogayot to check if leaving a "gap" between logical partitions numbers is acceptable. |
We can't though, this is just how logical partitions work -- logical partitions are basically a linked list and are numbered as you walk along the list so if you delete one, the partitions after that in the list get renumbered. At least that's my understanding -- I might be wrong! But that's why things are the way they are, for better or worse. |
62bfc5c
to
ad92d7a
Compare
Unfortunately, that is my understanding as well after reading more about the topic. Thanks for pointing this out. I'll drop my second patch. |
An actual gap (e.g., having partition 6 with no partition 5) is not a thing for logical partitions because of how numbering works. And while it seems theoretically possible to have partition N+1 before N in terms of physical location ; many partitioning tools expect the opposite. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
When deleting a partition, we used to renumber the logical partitions. There was two problems associated with this:
2. The renumbering also applied to partitions to preserve. This can break existing systems so let's make sure we stop renumbering if we run into a partition to preserve.NOTE: I must admit that the reasoning for doing this renumbering (and only doing it for logical partitions) is not clear to me.