diff --git a/subiquity/common/filesystem/manipulator.py b/subiquity/common/filesystem/manipulator.py index 8a171cde..2daa9213 100644 --- a/subiquity/common/filesystem/manipulator.py +++ b/subiquity/common/filesystem/manipulator.py @@ -152,20 +152,22 @@ class FilesystemManipulator: return getattr(self, 'delete_' + obj.type)(obj) - def clear(self, obj): + def clear(self, obj, wipe=None): if obj.type == "disk": obj.preserve = False - obj.wipe = 'superblock' + if wipe is None: + wipe = 'superblock' + obj.wipe = wipe for subobj in obj.fs(), obj.constructed_device(): self.delete(subobj) - def reformat(self, disk, ptable=None): + def reformat(self, disk, ptable=None, wipe=None): disk.grub_device = False if ptable is not None: disk.ptable = ptable for p in list(disk.partitions()): self.delete_partition(p, True) - self.clear(disk) + self.clear(disk, wipe) def can_resize_partition(self, partition): if not partition.preserve: diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index 53927442..c9d77b3d 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -133,28 +133,26 @@ class FilesystemController(SubiquityController, FilesystemManipulator): "autoinstall config did not create needed bootloader " "partition") - def guided_direct(self, disk): - self.reformat(disk) - gap = gaps.largest_gap(disk) - spec = { - "size": gap.size, - "fstype": "ext4", - "mount": "/", - } - self.partition_disk_handler(disk, spec, gap=gap) - - def guided_lvm(self, disk, lvm_options=None): - self.reformat(disk) + def setup_disk_for_guided(self, disk): + self.reformat(disk, wipe='superblock-recursive') if DeviceAction.TOGGLE_BOOT in DeviceAction.supported(disk): self.add_boot_disk(disk) - gap = gaps.largest_gap(disk) - size = sizes.get_bootfs_size(gap.size) - gap_boot, gap_rest = gap.split(size) - spec = dict(size=size, fstype="ext4", mount='/boot') + return gaps.largest_gap(disk) + + def guided_direct(self, disk): + gap = self.setup_disk_for_guided(disk) + spec = dict(fstype="ext4", mount="/") + self.create_partition(device=disk, gap=gap, spec=spec) + + def guided_lvm(self, disk, lvm_options=None): + gap = self.setup_disk_for_guided(disk) + gap_boot, gap_rest = gap.split(sizes.get_bootfs_size(gap.size)) + spec = dict(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) + part = self.create_partition( + device=disk, gap=gap_rest, spec=dict(fstype=None)) + vg_name = 'ubuntu-vg' i = 0 while self.model._one(type='lvm_volgroup', name=vg_name) is not None: