Skip to content
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

filesystem: Use the first fitting gap for ESP, instead of the largest gap #1764

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions subiquity/common/filesystem/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,22 @@ def get_add_part_plan(device, *, spec, args, resize_partition=None):
# is a bad idea. So avoid putting any sort of boot stuff on a logical -
# it's probably a bad idea for all cases.

gap = gaps.largest_gap(device, in_extended=False)
if gap is not None and gap.size >= size and gap.is_usable:
# find the first available gap (not always the largest one)
gap = next(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally prefer explicit for loops to this kind of thing but well

iter(
[
gap
for gap in gaps.parts_and_gaps(device)
if isinstance(gap, gaps.Gap)
and not gap.in_extended
and gap.size >= size
and gap.is_usable
]
),
None,
)

if gap is not None:
create_part_plan.gap = gap.split(size)[0]
return create_part_plan
elif resize_partition is not None and not resize_partition.is_logical:
Expand Down
Loading