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 19, 2024
1 parent d00a973 commit fc6917e
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 @@ -142,8 +144,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 @@ -153,6 +155,21 @@ def _clear_partitions(self, storage):
for mountpoint in self._request.reformatted_mount_points:
self._reformat_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 fc6917e

Please sign in to comment.