From 7602b7ee4da38096e355b805f0c3953e2b2630ba Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 10 Sep 2023 19:28:05 +0200 Subject: [PATCH 1/3] types/lvm_vg: disable preLVM for luks inside a logical volume this patch fixes opening a luks device on top of lvm in stage-1. previously, the preLVM flag would be set for luks devices even if they were part of a lvm logical volume, obviously requiring to be opened after lvm creating the logical volume's device. Co-authored-by: Emily --- lib/types/lvm_vg.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/types/lvm_vg.nix b/lib/types/lvm_vg.nix index 83397fb2..c43ed5f1 100644 --- a/lib/types/lvm_vg.nix +++ b/lib/types/lvm_vg.nix @@ -98,6 +98,9 @@ map (lv: [ (lib.optional (lv.content != null) lv.content._config) + (lib.optional ((lv.content.type or "") == "luks") { + boot.initrd.luks.devices.${lv.content.name}.preLVM = false; + }) (lib.optional (lv.lvm_type != null) { boot.initrd.kernelModules = [ "dm-${lv.lvm_type}" ]; }) From 4f61850c8765fdddf6a08ebe4d7a9ac70d434898 Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 10 Sep 2023 19:17:02 +0200 Subject: [PATCH 2/3] types/lvm_vg: enable swraid for raid lvm types this patch fixes mdraid not being enabled when using lvm's raid types, causing setup to fail as lvm relies on mdraid internally. Co-authored-by: Emily --- lib/types/lvm_vg.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/types/lvm_vg.nix b/lib/types/lvm_vg.nix index c43ed5f1..83e59467 100644 --- a/lib/types/lvm_vg.nix +++ b/lib/types/lvm_vg.nix @@ -101,9 +101,16 @@ (lib.optional ((lv.content.type or "") == "luks") { boot.initrd.luks.devices.${lv.content.name}.preLVM = false; }) - (lib.optional (lv.lvm_type != null) { - boot.initrd.kernelModules = [ "dm-${lv.lvm_type}" ]; - }) + (lib.optionals (lv.lvm_type != null) [ + { + boot.initrd.kernelModules = [ "dm-${lv.lvm_type}" ]; + } + (if lib.versionAtLeast (lib.versions.majorMinor lib.version) "23.11" then { + boot.swraid.enable = true; + } else { + boot.initrd.services.swraid.enable = true; + }) + ]) ]) (lib.attrValues config.lvs); description = "NixOS configuration"; From 636fed93bd849e44676bd3e9b9e0c32fa2301d2a Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 10 Sep 2023 20:10:37 +0200 Subject: [PATCH 3/3] types/lvm_vg: load mapper target kernel module before creating lv this fixes creating a logical volume of type raid0. Co-authored-by: Emily --- lib/types/lvm_vg.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/types/lvm_vg.nix b/lib/types/lvm_vg.nix index 83e59467..0e50325a 100644 --- a/lib/types/lvm_vg.nix +++ b/lib/types/lvm_vg.nix @@ -62,6 +62,8 @@ vgcreate ${config.name} \ "''${lvm_devices[@]}" ${lib.concatMapStrings (lv: '' + ${lib.optionalString (lv.lvm_type != null) "modprobe dm-${lv.lvm_type}"} + lvcreate \ --yes \ ${if lib.hasInfix "%" lv.size then "-l" else "-L"} ${lv.size} \