From 1144887c6f4d2dcbb2316a24364ef53e25b0fcfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 7 Dec 2023 00:07:29 +0100 Subject: [PATCH] lvm: update kernel modules when creating raid --- lib/types/lvm_vg.nix | 12 ++++++++++-- tests/lvm-raid.nix | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/types/lvm_vg.nix b/lib/types/lvm_vg.nix index bfe7ec7..714cb13 100644 --- a/lib/types/lvm_vg.nix +++ b/lib/types/lvm_vg.nix @@ -24,7 +24,8 @@ description = "Size of the logical volume"; }; 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? description = "LVM type"; }; @@ -99,7 +100,14 @@ (lv: [ (lib.optional (lv.content != null) lv.content._config) (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); diff --git a/tests/lvm-raid.nix b/tests/lvm-raid.nix index 736e0fd..b30332a 100644 --- a/tests/lvm-raid.nix +++ b/tests/lvm-raid.nix @@ -9,7 +9,7 @@ diskoLib.testLib.makeDiskoTest { machine.succeed("mountpoint /home"); ''; extraInstallerConfig = { - boot.kernelModules = [ "dm-raid0" "dm-mirror" ]; + boot.kernelModules = [ "dm-raid" "raid0" "dm-mirror" ]; }; extraSystemConfig = { # sadly systemd-boot fails to install to a raid /boot device