Skip to content

Commit

Permalink
filesystem: Use the first fitting gap for ESP, not always the largest
Browse files Browse the repository at this point in the history
  • Loading branch information
medicalwei committed Aug 16, 2023
1 parent b0f1030 commit 8b70d47
Showing 1 changed file with 16 additions and 2 deletions.
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(
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

0 comments on commit 8b70d47

Please sign in to comment.