Skip to content

Commit

Permalink
nixos/zfs: assert no force import with hibernation
Browse files Browse the repository at this point in the history
According to a ZFS issue about hibernation causing data corruption:
openzfs/zfs#12842

The way this happens is if the system force imports a pool that was
suspended during hibernation. I've had this happen twice on NixOS and
I'd like to avoid having this happen again, to me or others.

To do this I've added an assertion that makes sure you can't have
`forceImportRoot` or `forceImportAll` enabled with `allowHibernation`.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
  • Loading branch information
jakubgs committed Nov 28, 2022
1 parent 93de6bf commit 6b20a2f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nixos/modules/tasks/filesystems/zfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ in
assertion = !cfgZfs.forceImportAll || cfgZfs.forceImportRoot;
message = "If you enable boot.zfs.forceImportAll, you must also enable boot.zfs.forceImportRoot";
}
{
assertion = cfgZfs.allowHibernation -> !cfgZfs.forceImportRoot && !cfgZfs.forceImportAll;
message = "cfgZfs.allowHibernation while force importing is enabled will cause data corruption";
}
];

boot = {
Expand Down

0 comments on commit 6b20a2f

Please sign in to comment.