diff --git a/subiquity/common/filesystem/boot.py b/subiquity/common/filesystem/boot.py index cb148d55..a9f29f20 100644 --- a/subiquity/common/filesystem/boot.py +++ b/subiquity/common/filesystem/boot.py @@ -209,7 +209,7 @@ def get_add_part_plan(device, *, spec, args): create_part_plan = CreatePartPlan(gap=None, spec=spec, args=args) if gaps.largest_gap_size(device) >= size: - create_part_plan.gap = gaps.largest_gap(device) + create_part_plan.gap = gaps.largest_gap(device).split(size)[0] return create_part_plan else: new_parts = [p for p in partitions if not p.preserve] diff --git a/subiquity/common/filesystem/manipulator.py b/subiquity/common/filesystem/manipulator.py index e6ca3f51..1d59ceb9 100644 --- a/subiquity/common/filesystem/manipulator.py +++ b/subiquity/common/filesystem/manipulator.py @@ -220,6 +220,7 @@ class FilesystemManipulator: spec['size'], gap.size) spec['size'] = gap.size + gap = gap.split(spec['size'])[0] self.create_partition(disk, gap, spec) log.debug("Successfully added partition") diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index c0a265da..371fd8ff 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -148,18 +148,13 @@ class FilesystemController(SubiquityController, FilesystemManipulator): if DeviceAction.TOGGLE_BOOT in DeviceAction.supported(disk): self.add_boot_disk(disk) gap = gaps.largest_gap(disk) - self.create_partition( - device=disk, gap=gap, spec=dict( - size=sizes.get_bootfs_size(disk), - fstype="ext4", - mount='/boot' - )) - gap = gaps.largest_gap(disk) - part = self.create_partition( - device=disk, gap=gap, spec=dict( - size=gaps.largest_gap_size(disk), - fstype=None, - )) + size = sizes.get_bootfs_size(disk) + gap_boot, gap_rest = gap.split(size) + spec = dict(size=size, fstype="ext4", mount='/boot') + self.create_partition(device=disk, gap=gap_boot, spec=spec) + + spec = dict(size=gap_rest.size, fstype=None) + part = self.create_partition(device=disk, gap=gap_rest, spec=spec) vg_name = 'ubuntu-vg' i = 0 while self.model._one(type='lvm_volgroup', name=vg_name) is not None: @@ -376,7 +371,8 @@ class FilesystemController(SubiquityController, FilesystemManipulator): 'mount': data.partition.mount, } - self.create_partition(disk, data.gap, spec, wipe='superblock') + gap = gaps.at_offset(disk, data.gap.offset).split(requested_size)[0] + self.create_partition(disk, gap, spec, wipe='superblock') return await self.v2_GET() async def v2_delete_partition_POST(self, data: ModifyPartitionV2) \