From a53858010b576291eda47035fbaa77ab40bf33c7 Mon Sep 17 00:00:00 2001 From: "Bryan A. S" Date: Thu, 5 May 2022 11:42:44 -0300 Subject: [PATCH] nixos/zfs: introduce option to control hibernation --- .../from_md/release-notes/rl-2211.section.xml | 12 ++++++++++++ nixos/doc/manual/release-notes/rl-2211.section.md | 2 ++ nixos/modules/tasks/filesystems/zfs.nix | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml index 1af4ce4bf980..2c65f7878932 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml @@ -847,6 +847,18 @@ hardware.saleae-logic.package. + + + ZFS module will not allow hibernation by default, this is a + safety measure to prevent data loss cases like the ones + described at + OpenZFS/260 + and + OpenZFS/12842. + Use the boot.zfs.allowHibernation option to + configure this behaviour. + + The Redis module now disables RDB persistence when diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md index b5adc0d8a363..338ef119a99c 100644 --- a/nixos/doc/manual/release-notes/rl-2211.section.md +++ b/nixos/doc/manual/release-notes/rl-2211.section.md @@ -274,6 +274,8 @@ Available as [services.patroni](options.html#opt-services.patroni.enable). - A new module was added for the Saleae Logic device family, providing the options `hardware.saleae-logic.enable` and `hardware.saleae-logic.package`. +- ZFS module will not allow hibernation by default, this is a safety measure to prevent data loss cases like the ones described at [OpenZFS/260](https://github.com/openzfs/zfs/issues/260) and [OpenZFS/12842](https://github.com/openzfs/zfs/issues/12842). Use the `boot.zfs.allowHibernation` option to configure this behaviour. + - The Redis module now disables RDB persistence when `services.redis.servers..save = []` instead of using the Redis default. - Neo4j was updated from version 3 to version 4. See this [migration guide](https://neo4j.com/docs/upgrade-migration-guide/current/) on how to migrate your Neo4j instance. diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index 96222f3b4f64..4b4f4cc801ab 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -226,6 +226,15 @@ in ''; }; + allowHibernation = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc '' + Allow hibernation support, this may be a unsafe option depending on your + setup. Make sure to NOT use Swap on ZFS. + ''; + }; + extraPools = mkOption { type = types.listOf types.str; default = []; @@ -498,6 +507,10 @@ in boot = { kernelModules = [ "zfs" ]; + # https://github.com/openzfs/zfs/issues/260 + # https://github.com/openzfs/zfs/issues/12842 + # https://github.com/NixOS/nixpkgs/issues/106093 + kernelParams = lib.optionals (!config.boot.zfs.allowHibernation) [ "nohibernate" ]; extraModulePackages = [ (if config.boot.zfs.enableUnstable then