Skip to content

Commit

Permalink
home reuse: check autopartitioning scheme against reused mountpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
rvykydal committed Sep 18, 2024
1 parent 210c7dd commit 06b5bb9
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
get_default_partitioning, get_part_spec, get_disks_for_implicit_partitions
from pyanaconda.modules.storage.platform import platform
from pyanaconda.core.storage import suggest_swap_size
from pykickstart.constants import AUTOPART_TYPE_BTRFS, AUTOPART_TYPE_LVM, \
AUTOPART_TYPE_LVM_THINP, AUTOPART_TYPE_PLAIN


log = get_module_logger(__name__)
Expand Down Expand Up @@ -143,8 +145,8 @@ def _clear_partitions(self, storage):
storage.roots = find_existing_installations(storage.devicetree)
log.debug("storage.roots.mounts %s", [root.mounts for root in storage.roots])

# TODO check that partitioning scheme matches - do it earlier in the
# check but also here?
# Check that partitioning scheme matches
self._check_reused_scheme(storage, self._request)

for mountpoint in self._request.removed_mount_points:
if mountpoint == "bootloader":
Expand All @@ -154,6 +156,21 @@ def _clear_partitions(self, storage):
for mountpoint in self._request.erased_mount_points:
self._erase_mountpoint(storage, mountpoint)

def _check_reused_scheme(self, storage, request):
scheme = request.partitioning_scheme
required_home_device_type = {
AUTOPART_TYPE_BTRFS: "btrfs subvolume",
AUTOPART_TYPE_LVM: "lvmlv",
AUTOPART_TYPE_LVM_THINP: "lvmthinlv",
AUTOPART_TYPE_PLAIN: "partition",
}
for mountpoint in request.reused_mount_points:
device = self._get_mountpoint_device(storage, mountpoint)
if device.type != required_home_device_type[scheme]:
raise StorageError(_("Reused device type '{}' of mountpoint '{}' does not "
"match the required automatic partitioning scheme.")
.format(device.type, mountpoint))

def _schedule_reused_mountpoint(self, storage, mountpoint):
device = self._get_mountpoint_device(storage, mountpoint)
log.debug("add mount device request for reused mountpoint: %s device: %s",
Expand Down

0 comments on commit 06b5bb9

Please sign in to comment.