| 10 May 2026 |
Albert Larsan | I never got a file-based hibernation working on btrfs, that is why I have my onion. | 14:20:54 |
sudoforge | @rajil:rajils.com both of the links you provided are related to using swap (and hibernation) on a zfs zvol.
what we've described here is setting up swap on a secondary (or tertiary) partition, without formatting it as ZFS.
| 14:23:47 |
sudoforge | i have file-based swap under encrypted btrfs on my laptop working and don't recall having to do anything special. did you last try this several years ago, perhaps? | 14:25:32 |
trumee | yes, i have a separate non-zfs swap partition. But ZFS does not like hibernate, there could be pool corruption. | 14:25:40 |
Albert Larsan | I tried about two years ago, on a Fedora system (with an Nvidia graphic card). When I made the switch to NixOS (on my current laptop), I decided it wasn’t worth the trouble (especially with impermanence and other stuff) | 14:30:08 |
Albert | I had success with this guide
https://sawyershepherd.org/post/hibernating-to-an-encrypted-swapfile-on-btrfs-with-nixos/ | 14:33:18 |
sudoforge | i'm not sure that's the case; the openzfs disk formatting guide even explicitly instructs users to create a swap partition. | 14:33:53 |
sudoforge | (in case this isn't clear to you trumee - the swap partition is not formatted with zfs and is not a zvol) | 15:13:56 |
dantefromhell | I've been doing ZFS & swap on a separate partition + hibernate on multiple devices for multiple years w/o pool corruption #DataPoint | 15:16:27 |
trumee | Yes, my swap is ext4. | 15:16:36 |
sudoforge | well that makes sense, since zfs has nothing to do with the swap partition | 15:16:47 |
sudoforge | * dantefromhell well that makes sense, since zfs has nothing to do with the swap partition | 15:17:17 |
sudoforge | then you should be good to go! | 15:17:40 |
trumee | did you set this up, https://wiki.nixos.org/wiki/ZFS#Partial_support_for_swap_on_ZFS ? | 15:18:21 |
trumee | Wiki does not recommend boot.zfs.allowHibernation = true | 15:19:05 |
sudoforge | because this is for hibernation on swap space that is on a zvol | 15:19:56 |
sudoforge | you're conflating "i use zfs on /some/partition and have a separate ext4 fs on /another/partition" with "zfs is managing my entire disk" | 15:20:31 |
trumee | so that option is irrelevant for my ext4 setup i suppose | 15:20:57 |
sudoforge | correct. | 15:21:06 |
trumee | so i just need to set boot.resumeDevice ? | 15:22:07 |
sudoforge | well, you need to specify the swap device too. see: https://wiki.nixos.org/wiki/Power_Management#Hibernation | 15:23:14 |
trumee | do i need to turn off randomEncryption?,
swapDevices = [
{
device = "/dev/sda3";
randomEncryption.enable = true;
}
| 15:26:23 |
sudoforge | yes; random encryption is not compatible with hibernation, since you don't know the key used to unlock it when you resume | 15:27:34 |
sudoforge | you can encrypt it with a known key (passphrase, security key, clevis+tang) instead | 15:28:13 |
sudoforge | you can optionally encrypt it and add the TPM device as a key, allowing you to automatically decrypt it | 15:28:48 |
sudoforge | * you can optionally encrypt it and add the TPM device as a key, allowing you to automatically decrypt it. this is inherently less secure, though. | 15:29:09 |
dantefromhell | In reply to @rajil:rajils.com did you set this up, https://wiki.nixos.org/wiki/ZFS#Partial_support_for_swap_on_ZFS ? nope... IIRC when I created my disk layouts (i'm using disko everywhere) swap on zvol was discouraged too | 15:29:37 |
trumee | i use a yubikey to decrypt on bootup. | 15:29:57 |
sudoforge | to decrypt what, though | 15:30:23 |
sudoforge | your zfs pool, i'm guessing | 15:30:39 |