Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "dm-snapshot" to kernelModules? #33646

Closed
jluttine opened this issue Jan 9, 2018 · 5 comments · Fixed by #62969
Closed

Add "dm-snapshot" to kernelModules? #33646

jluttine opened this issue Jan 9, 2018 · 5 comments · Fixed by #62969

Comments

@jluttine
Copy link
Member

jluttine commented Jan 9, 2018

Issue description

After creating an LVM snapshot, system doesn't boot.

Steps to reproduce

I took an LVM snapshot when running my system:

modprobe dm-snapshot
lvcreate -l100%FREE -s -n lv-nixos-snapshot /dev/vg-nixos/lv-nixos

Rebooted my system at some point later and got stuck in the boot with error something like: snapshot target support missing from kernel. I suppose it's because modprobe dm-snapshot isn't run. How can I make my system load that automatically?

This is probably related: https://bugzilla.redhat.com/show_bug.cgi?id=1287940

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the
results.

@jluttine
Copy link
Member Author

jluttine commented Jan 9, 2018

I managed to boot my system by booting into a live USB OS, and then removing the snapshot lvremove /dev/vg-nixos/lv-nixos-snapshot and booting normally after that. But obviously I'd like the boot to work even if there are snapshots present.

@bjornfor
Copy link
Contributor

bjornfor commented Jan 9, 2018

Perhaps boot.initrd.kernelModules = [ "dm-snapshot" ]? (UPDATE: Yes, that's it.)

@bjornfor
Copy link
Contributor

bjornfor commented Feb 8, 2018

Perhaps nixos-generate-config could detect LVM and add this setting automatically?

@jluttine
Copy link
Member Author

I can confirm that adding boot.initrd.kernelModules = [ "dm-snapshot" ] solved the issue. I also tried boot.kernelModules = [ "dm-snapshot" ] and boot.initrd.availableKernelModules = [ "dm-snapshot" ] but they didn't help. I would like to see this option added by default (when LVM detected?) so users wouldn't so easily make their systems unbootable.

@jluttine jluttine changed the title System unbootable if LVM snapshots present Add "dm-snapshot" to kernelModules? Feb 20, 2018
@bjornfor
Copy link
Contributor

Step 1, LVM detection. Here is an idea: test $(lsblk -n -o TYPE $(findmnt -n -o SOURCE /)) = lvm && echo "is lvm". (Is there a better way?)

Step 2. update nixos-generate-config.

bjornfor added a commit to bjornfor/nixpkgs that referenced this issue Jun 16, 2019
Without this, the system becomes unbootable if the user creates a LVM
snapshot and reboots.

Fixes NixOS#33646

(The same kind of problem was fixed in RHEL a few years back:
https://bugzilla.redhat.com/show_bug.cgi?id=1287940)
bjornfor added a commit that referenced this issue Jun 16, 2019
Without this, the system becomes unbootable if the user creates a LVM
snapshot and reboots.

Fixes #33646

(The same kind of problem was fixed in RHEL a few years back:
https://bugzilla.redhat.com/show_bug.cgi?id=1287940)
bjornfor added a commit that referenced this issue Jun 16, 2019
Without this, the system becomes unbootable if the user creates a LVM
snapshot and reboots.

Fixes #33646

(The same kind of problem was fixed in RHEL a few years back:
https://bugzilla.redhat.com/show_bug.cgi?id=1287940)

(cherry picked from commit 4213e48)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants