3
0
Fork 0
forked from mirrors/nixpkgs

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)
This commit is contained in:
Bjørn Forsman 2019-06-10 21:59:01 +02:00
parent 9e45f6feac
commit 4213e48dd9

View file

@ -264,6 +264,11 @@ if (scalar @bcacheDevices > 0) {
push @initrdAvailableKernelModules, "bcache"; 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`; my $virt = `systemd-detect-virt`;
chomp $virt; chomp $virt;
@ -526,6 +531,7 @@ sub multiLineList {
} }
my $initrdAvailableKernelModules = toNixStringList(uniq @initrdAvailableKernelModules); my $initrdAvailableKernelModules = toNixStringList(uniq @initrdAvailableKernelModules);
my $initrdKernelModules = toNixStringList(uniq @initrdKernelModules);
my $kernelModules = toNixStringList(uniq @kernelModules); my $kernelModules = toNixStringList(uniq @kernelModules);
my $modulePackages = toNixList(uniq @modulePackages); my $modulePackages = toNixList(uniq @modulePackages);
@ -545,6 +551,7 @@ my $hwConfig = <<EOF;
imports =${\multiLineList(" ", @imports)}; imports =${\multiLineList(" ", @imports)};
boot.initrd.availableKernelModules = [$initrdAvailableKernelModules ]; boot.initrd.availableKernelModules = [$initrdAvailableKernelModules ];
boot.initrd.kernelModules = [$initrdKernelModules ];
boot.kernelModules = [$kernelModules ]; boot.kernelModules = [$kernelModules ];
boot.extraModulePackages = [$modulePackages ]; boot.extraModulePackages = [$modulePackages ];
$fsAndSwap $fsAndSwap