git.iko.soy/typeable/nixpkgs
on master help sign in
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)

commit4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc authorBjørn Forsman <bjorn.forsman@gmail.com> dateMon 10 Jun 2019, 21:59 (7 years ago) parent9e45f6f
1 file changed+7
nixos/modules/installer/tools/nixos-generate-config.pl+7
nixos/modules/installer/tools/nixos-generate-config.pl+7
@@ -264,6 +264,11 @@ if (scalar @bcacheDevices > 0) {
264264 push @initrdAvailableKernelModules, "bcache";
265265}
266266
267+# Prevent unbootable systems if LVM snapshots are present at boot time.
268+if (`lsblk -o TYPE` =~ "lvm") {
269+ push @initrdKernelModules, "dm-snapshot";
270+}
271+
267272my $virt = `systemd-detect-virt`;
268273chomp $virt;
269274
@@ -526,6 +531,7 @@ sub multiLineList {
526531}
527532
528533my $initrdAvailableKernelModules = toNixStringList(uniq @initrdAvailableKernelModules);
534+my $initrdKernelModules = toNixStringList(uniq @initrdKernelModules);
529535my $kernelModules = toNixStringList(uniq @kernelModules);
530536my $modulePackages = toNixList(uniq @modulePackages);
531537
@@ -545,6 +551,7 @@ my $hwConfig = <<EOF;
545551 imports =${\multiLineList(" ", @imports)};
546552
547553 boot.initrd.availableKernelModules = [$initrdAvailableKernelModules ];
554+ boot.initrd.kernelModules = [$initrdKernelModules ];
548555 boot.kernelModules = [$kernelModules ];
549556 boot.extraModulePackages = [$modulePackages ];
550557$fsAndSwap