From 1f8e67e945fcfc54bfca5c4d082569b3115a466b Mon Sep 17 00:00:00 2001 From: r-vdp Date: Wed, 25 Sep 2024 09:30:14 +0200 Subject: [PATCH] Always add dm-snapshot when LVM is used The lvm_type is only set on RAID and thinly provisioned LVM volumes, but regular LVM volumes without a type can also have snapshots. --- lib/types/lvm_vg.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/types/lvm_vg.nix b/lib/types/lvm_vg.nix index 2a5cfe1..cb2c750 100644 --- a/lib/types/lvm_vg.nix +++ b/lib/types/lvm_vg.nix @@ -1,9 +1,14 @@ { config, options, lib, diskoLib, ... }: let # Load kernel modules to ensure device mapper types are available - kernelModules = lib.filter (x: x != "") (map - (lv: lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "dm-${lv.lvm_type}") - (lib.attrValues config.lvs)); + kernelModules = + [ + # Prevent unbootable systems if LVM snapshots are present at boot time. + "dm-snapshot" + ] ++ + lib.filter (x: x != "") (map + (lv: lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "dm-${lv.lvm_type}") + (lib.attrValues config.lvs)); in { options = { @@ -131,8 +136,6 @@ in (lib.optional (lv.content != null) lv.content._config) (lib.optional (lv.lvm_type != null) { boot.initrd.kernelModules = [ - # Prevent unbootable systems if LVM snapshots are present at boot time. - "dm-snapshot" (if lv.lvm_type == "mirror" then "dm-mirror" else "dm-raid") ] ++ lib.optional (lv.lvm_type == "raid0") "raid0"