lvm: update kernel modules when creating raid

This commit is contained in:
Jörg Thalheim 2023-12-07 00:07:29 +01:00 committed by mergify[bot]
parent c7f594c2ab
commit 1144887c6f
2 changed files with 11 additions and 3 deletions

View File

@ -24,7 +24,8 @@
description = "Size of the logical volume"; description = "Size of the logical volume";
}; };
lvm_type = lib.mkOption { lvm_type = lib.mkOption {
type = lib.types.nullOr (lib.types.enum [ "mirror" "raid0" "raid1" "raid5" "raid6" ]); # TODO add all lib.types # TODO: add raid10
type = lib.types.nullOr (lib.types.enum [ "mirror" "raid0" "raid1" "raid4" "raid5" "raid6" ]); # TODO add all lib.types
default = null; # maybe there is always a default type? default = null; # maybe there is always a default type?
description = "LVM type"; description = "LVM type";
}; };
@ -99,7 +100,14 @@
(lv: [ (lv: [
(lib.optional (lv.content != null) lv.content._config) (lib.optional (lv.content != null) lv.content._config)
(lib.optional (lv.lvm_type != null) { (lib.optional (lv.lvm_type != null) {
boot.initrd.kernelModules = [ "dm-${lv.lvm_type}" ]; boot.initrd.kernelModules = [(if lv.lvm_type == "mirror" then "dm-mirror" else "dm-raid")]
++ lib.optional (lv.lvm_type == "raid0") "raid0"
++ lib.optional (lv.lvm_type == "raid1") "raid1"
# ++ lib.optional (lv.lvm_type == "raid10") "raid10"
++ lib.optional (lv.lvm_type == "raid4" ||
lv.lvm_type == "raid5" ||
lv.lvm_type == "raid6") "raid456";
}) })
]) ])
(lib.attrValues config.lvs); (lib.attrValues config.lvs);

View File

@ -9,7 +9,7 @@ diskoLib.testLib.makeDiskoTest {
machine.succeed("mountpoint /home"); machine.succeed("mountpoint /home");
''; '';
extraInstallerConfig = { extraInstallerConfig = {
boot.kernelModules = [ "dm-raid0" "dm-mirror" ]; boot.kernelModules = [ "dm-raid" "raid0" "dm-mirror" ];
}; };
extraSystemConfig = { extraSystemConfig = {
# sadly systemd-boot fails to install to a raid /boot device # sadly systemd-boot fails to install to a raid /boot device