Skip to content

Commit

Permalink
home reuse: check that reused system and autopart scheme matches
Browse files Browse the repository at this point in the history
  • Loading branch information
rvykydal committed Sep 19, 2024
1 parent 7bf019e commit 08884e3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/apis/storage_partitioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,19 @@ export const partitioningSetEncrypt = ({ encrypt, partitioning }) => {
export const partitioningSetHomeReuse = async ({ partitioning }) => {
const request = await getPartitioningRequest({ partitioning });

// In general default scheme defined in conf.Storage.default-scheme would be used
// Only btrfs (AUTOPART_TYPE_BTRFS) autopartitioning scheme is supported now
request["partitioning-scheme"] = cockpit.variant("i", 1);
// These settings work also for AUTOPART_TYPE_LVM, AUTOPART_TYPE_LVM_THINP schemes
request["erased-mount-points"] = cockpit.variant("as", ["/"]);
request["reused-mount-points"] = cockpit.variant("as", ["/home"]);
request["removed-mount-points"] = cockpit.variant("as", ["/boot", "bootloader"]);

// Settings for AUTOPART_TYPE_PLAIN
// request["partitioning-scheme"] = cockpit.variant("i", 0);
// request["reused-mount-points"] = cockpit.variant("as", ["/home"]);
// request["removed-mount-points"] = cockpit.variant("as", ["/", "/boot", "bootloader"]);

await setPartitioningRequest({ partitioning, request });
};

Expand Down
16 changes: 15 additions & 1 deletion src/components/storage/InstallationScenario.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,24 @@ const checkHomeReuse = ({ devices, originalExistingSystems, selectedDisks }) =>
return availability;
}

// Check that required autopartitioning scheme matches reused OS.
// Currently only btrfs scheme is supported.
// btrfs is enforced in partitioningSetHomeReuse, but in general we should rather
// use conf.Storage.default-scheme.
// Check just "/home". To be more generic we could check all reused devices (as the backend).
const reusedOS = linuxSystems[0];
const homeDevice = reusedOS["mount-points"].v["/home"];
const requiredType = "btrfs subvolume";
if (devices[homeDevice].type.v !== requiredType) {
availability.available = false;
availability.reason = _("No reusable existing Linux system found");
availability.hint = cockpit.format(_("Reused devices must have '$0' type"), requiredType);
return availability;
}

// TODO checks:
// - luks - partitions are unlocked - enforce? allow opt-out?
// - size ?
// - matching partitioning scheme? we support only btrfs now, set the scheme automatically in backend?
// - Windows system along (forbidden for now?)

return availability;
Expand Down

0 comments on commit 08884e3

Please sign in to comment.