From 4213e48dd9779e2ad770dc48c25e5eae0dfb3fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Mon, 10 Jun 2019 21:59:01 +0200 Subject: [PATCH] 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) --- nixos/modules/installer/tools/nixos-generate-config.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index 9a1157d95013..4c255ad47869 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 = <