Thanks for this. So weird though - I literally spent the better part of the weekend reading and learning all about the differences between zram and zswap and ultimately deciding to switch out my previous zram config for zswap on my NixOS system! So seeing this pop up on my hackernews feed felt a bit spooky…
same, I literally just set up my Framework 13 Pro today and was looking for the current recommended zswap settings... looks like a bunch of us are in this thread
Right, you are good to do swap files on btrfs since linux 5.0 or so as long as you follow some rules. Disko thankfully covers all those details for you, but I shouldn't have skipped over that in the piece. I'll make an update when I get a chance.
Swap files work, but I wouldn't quite say "you are good to do swap files on btrfs" because the official documentation (the page I linked earlier) says
filesystem - must be only single device
This means swapfiles will have an amplified impact, much larger than the size of the swapfile itself.
Users should be aware of the impact when using swapfiles alongside other data. This is especially discouraged for root filesystem.
If a swap file is the only thing that will work with your setup, then it's fine to use one, but if you're at all able to use a swap partition, then that's a far better choice. (Swap files are fine on ext4 and xfs; it's only COW filesystems like btrfs and zfs where they should be avoided.)
I've had good luck using zswap+zstd on Ubuntu 26.04. I have a Framework 13 (AMD) with 16GB, and have a 16GB swap file configured (ext4 root partition).
I had planned to upgrade the machine to 32GB of RAM but I don't really feel it's necessary at this point. Which is obviously great given the current RAM costs!
I also just recently enabled zswap on my NixOS setup, it's been working fine. I have 32GB of RAM and 64GB of swap, so I really don't need it, but it hasn't hurt.
I was expecting some problems with my switch to NixOS back in June, but it's been just superb. Even things like building deb packages for my Ubuntu 26.04 machines at work have not been a problem at all.
I had dabbled with NixOS for a year or two before making the switch and had some familiarity with the nixlang and various concepts (SOPS, age, flakes). But, what really smoothed out the switch was using Claude Code to develop the NixOS configs. Everything is easy to do that way, and any issues are easy to back out.
Thanks for this. So weird though - I literally spent the better part of the weekend reading and learning all about the differences between zram and zswap and ultimately deciding to switch out my previous zram config for zswap on my NixOS system! So seeing this pop up on my hackernews feed felt a bit spooky…
same, I literally just set up my Framework 13 Pro today and was looking for the current recommended zswap settings... looks like a bunch of us are in this thread
I agree with everything else here, but swap files on btrfs should probably be avoided whenever possible [0].
[0]: https://btrfs.readthedocs.io/en/latest/Swapfile.html
Right, you are good to do swap files on btrfs since linux 5.0 or so as long as you follow some rules. Disko thankfully covers all those details for you, but I shouldn't have skipped over that in the piece. I'll make an update when I get a chance.
Swap files work, but I wouldn't quite say "you are good to do swap files on btrfs" because the official documentation (the page I linked earlier) says
If a swap file is the only thing that will work with your setup, then it's fine to use one, but if you're at all able to use a swap partition, then that's a far better choice. (Swap files are fine on ext4 and xfs; it's only COW filesystems like btrfs and zfs where they should be avoided.)
I've had good luck using zswap+zstd on Ubuntu 26.04. I have a Framework 13 (AMD) with 16GB, and have a 16GB swap file configured (ext4 root partition).
I had planned to upgrade the machine to 32GB of RAM but I don't really feel it's necessary at this point. Which is obviously great given the current RAM costs!
I also just recently enabled zswap on my NixOS setup, it's been working fine. I have 32GB of RAM and 64GB of swap, so I really don't need it, but it hasn't hurt.
I was expecting some problems with my switch to NixOS back in June, but it's been just superb. Even things like building deb packages for my Ubuntu 26.04 machines at work have not been a problem at all.
I had dabbled with NixOS for a year or two before making the switch and had some familiarity with the nixlang and various concepts (SOPS, age, flakes). But, what really smoothed out the switch was using Claude Code to develop the NixOS configs. Everything is easy to do that way, and any issues are easy to back out.