summary refs log tree commit diff
path: root/nixos/modules/installer/tools/nixos-generate-config.pl
diff options
context:
space:
mode:
authorBjørn Forsman <bjorn.forsman@gmail.com>2019-06-10 21:59:01 +0200
committerBjørn Forsman <bjorn.forsman@gmail.com>2019-06-16 15:30:54 +0200
commit4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc (patch)
treef8eb6d0c2bd446ee4de3916ec751800bf2e7d72b /nixos/modules/installer/tools/nixos-generate-config.pl
parent9e45f6feac633fdc41eaaaa1ad65d77bda252472 (diff)
downloadnixpkgs-4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc.tar
nixpkgs-4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc.tar.gz
nixpkgs-4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc.tar.bz2
nixpkgs-4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc.tar.lz
nixpkgs-4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc.tar.xz
nixpkgs-4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc.tar.zst
nixpkgs-4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc.zip
nixos-generate-config: add dm-snapshot module if LVM is detected
Without this, the system becomes unbootable if the user creates a LVM
snapshot and reboots.

Fixes https://github.com/NixOS/nixpkgs/issues/33646

(The same kind of problem was fixed in RHEL a few years back:
https://bugzilla.redhat.com/show_bug.cgi?id=1287940)
Diffstat (limited to 'nixos/modules/installer/tools/nixos-generate-config.pl')
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl7
1 files changed, 7 insertions, 0 deletions
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index 9a1157d9501..4c255ad4786 100644
--- a/nixos/modules/installer/tools/nixos-generate-config.pl
+++ b/nixos/modules/installer/tools/nixos-generate-config.pl
@@ -264,6 +264,11 @@ if (scalar @bcacheDevices > 0) {
     push @initrdAvailableKernelModules, "bcache";
 }
 
+# Prevent unbootable systems if LVM snapshots are present at boot time.
+if (`lsblk -o TYPE` =~ "lvm") {
+    push @initrdKernelModules, "dm-snapshot";
+}
+
 my $virt = `systemd-detect-virt`;
 chomp $virt;
 
@@ -526,6 +531,7 @@ sub multiLineList {
 }
 
 my $initrdAvailableKernelModules = toNixStringList(uniq @initrdAvailableKernelModules);
+my $initrdKernelModules = toNixStringList(uniq @initrdKernelModules);
 my $kernelModules = toNixStringList(uniq @kernelModules);
 my $modulePackages = toNixList(uniq @modulePackages);
 
@@ -545,6 +551,7 @@ my $hwConfig = <<EOF;
   imports =${\multiLineList("    ", @imports)};
 
   boot.initrd.availableKernelModules = [$initrdAvailableKernelModules ];
+  boot.initrd.kernelModules = [$initrdKernelModules ];
   boot.kernelModules = [$kernelModules ];
   boot.extraModulePackages = [$modulePackages ];
 $fsAndSwap