Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Commit

Permalink
nixos-generate-config: add dm-snapshot module if LVM is detected
Browse files Browse the repository at this point in the history
Without this, the system becomes unbootable if the user creates a LVM
snapshot and reboots.

Fixes NixOS/nixpkgs#33646

(The same kind of problem was fixed in RHEL a few years back:
https://bugzilla.redhat.com/show_bug.cgi?id=1287940)
  • Loading branch information
bjornfor committed Jun 16, 2019
1 parent 9e45f6f commit 4213e48
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nixos/modules/installer/tools/nixos-generate-config.pl
Expand Up @@ -264,6 +264,11 @@ sub usbCheck {
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;

Expand Down Expand Up @@ -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);

Expand All @@ -545,6 +551,7 @@ sub multiLineList {
imports =${\multiLineList(" ", @imports)};
boot.initrd.availableKernelModules = [$initrdAvailableKernelModules ];
boot.initrd.kernelModules = [$initrdKernelModules ];
boot.kernelModules = [$kernelModules ];
boot.extraModulePackages = [$modulePackages ];
$fsAndSwap
Expand Down

0 comments on commit 4213e48

Please sign in to comment.