Code change:
Describe the bug Suspend to disk / hibernation in combination with ZFS may lead to filesystem corruption. To Reproduce The problem only shows up occasionally about once on every 30 startups. I had been using suspend to disk on my laptop without problem for several years. After changing from BTRFS to ZFS the import of the ZFS pool occasionally stalls when resuming from hibernate. A message says that the pool is corrupted and gets reconstructed. Once the pool was corrupted irreparably. Root cause ZFS does not support filesystem freeze and thaw under Linux at the moment. (see ) The problem is that when resuming from hibernation the initrd tries to import the pool (it also tries to fix a corrupted pool and effectively modifies the pool/partition). This happens before checks for a possible resume from hibernation and before the system returns to the state in which it had been suspended. Expected behavior It may be possible to fix the problem by reordering the sequence of actions in initrd. Unless there is a fix for this NixOS should disable the combination of ZFS and hibernation. (More precisely, initrd should either contain the setup scripts for ZFS or the scripts for return-from-hibernate). At least there should be a warning.
BTRFS is native to Linux, so its suspension mechanism and Linux's were (presumably) always set up to work with each other. On the other hand, ZFS's suspension code has not yet been hooked up to Linux's properly: I agree that— One potential problem seems to be that there seem to be multiple packages that can cause suspension. In my NixOS configuration, I tell and not to suspend, but I don't know whether that's everything that might cause suspension.
Thanks for adding the link. I've a corresponding line of warning here:
Do you suspend to disk with a zvol swap? Because I'm running with root on ZFS on my laptop and I have never encountered problems with suspend to disk, but I'm also using a separate regular swap partition.
I for one use a regular swap partition. I recall hearing that swap-on-ZVOL is dangerous independently of hibernation.
I marked this as stale due to inactivity. &rarr;
Would it make sense to automatically add in cases where zfs is in use?
This. A note in wiki or manual will be good too. EDIT: Done ().
I marked this as stale due to inactivity. &rarr;
Let's see if we can close this with
This issue has been mentioned on NixOS Discourse. There might be relevant details there:

Related discussion:
text: - A new module was added for the Saleae Logic device family, providing the options `hardware.saleae-logic.enable` and `hardware.saleae-logic.package`. <ins> - 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. </ins> - The Redis module now disables RDB persistence when `services.redis.servers.<name>.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.