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.
This commit is contained in:
r-vdp committed 2024-09-25 09:30:14 +02:00
1 parent 6d42596a35
commit 1f8e67e945
1 file changed
+8 -5
+8 -5
View File
@@ -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"