diff options
author | Jakub Sokołowski <jakub@status.im> | 2022-11-28 13:35:48 +0100 |
---|---|---|
committer | Jakub Sokołowski <jakub@status.im> | 2022-12-17 13:11:23 +0100 |
commit | c70f0473153c63ad1cf6fbea19f290db6b15291f (patch) | |
tree | d6924d5766ee963a55a48ccd70e64d07250d4dc1 /nixos | |
parent | 2b534fee3d5bbee6944de149b312dbf3b4b71052 (diff) |
nixos/zfs: assert no force import with hibernation
According to a ZFS issue about hibernation causing data corruption: https://github.com/openzfs/zfs/issues/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>
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/tasks/filesystems/zfs.nix | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index 4b4f4cc801aba..0f14f2b501c22 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -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 = "boot.zfs.allowHibernation while force importing is enabled will cause data corruption"; + } ]; boot = { |