You may note that you can set a priority in the order swap space is used, and in most cases never need or use anything more than the default zram space. Using priorities would ensure that only after zram was full would the system begin swapping to a swapfile or partition.
There are cases where the kernel runs out of memory and it cannot do the I/O.I believe the zram helps in these cases.
@barryascott, if I’ve been hitting that, then it might make sense that SysRq didn’t work, perhaps.
Considering that, why would Changes/SwapOnZRAM - Fedora Project Wiki have been accepted?
Hibernation is already stressful to memory-management subsystem and prone to bailing out in such cases. The swap-on-zram will be favored for evictions in the attempt to free memory to create the hibernation image. It could increase instances of hibernation entry failure. This isn’t a crash, it just means the attempt doesn’t succeed, and the system resumes operation instead of hibernating.
It seems silly to me to not even ask the user whether they want to create a swap partition during installation, but I shouldn’t be as technically competent as the author of that.
@computersavvy, that sounds very much like Windows’s implementation, and what I’ve requested. Thanks. I’ll investigate if I’m competent enough to.
Not at all. Windows has been totally dynamic and resulted in a fragmented swap file spread across multiple locations in the file system. As I recall from windows95 & 98 days it was possible to delete the default (often fragmented) swapfile and create a new single contiguous file large enough that it was then not normally subject to random expansion and fragmenting. Doing so at times made a noticeable improvement in performance.
For Linux the user must define swap files or partitions and they are not fragmented within the swap spaces. Though it is possible to have more than one segment that linux uses in sequence, the best practice is to have one swap space large enough to not ever fill up.
@computersavvy, in which case, Fedora’s decision to not create one by default is even more perplexing. I come from openSUSE TW, which does by default. Is this merely a matter of Fedora having insensible defaults?
The creation of a swap partition by default was dropped in Fedora Linux 33 with the addition of Swap on ZRAM. Prior to that, Fedora Linux did create swap partitions by default. The change might be interrelated with the switch to Btrfs. I think there has been a move to simplify the partitioning and to try to use Btrfs subvolumes instead. (Swap might not work well on a Btrfs filesystem and that might be why ZRAM was chosen. I know there are issues with using ZFS volumes as a backing for swap memory. I don’t know if Btrfs has any similar problems, but it wouldn’t surprise me.)
Perhaps, @glb, although OSTW uses BTRFS by default too.
No it’s nothing to do with btrfs. It to do with disk being to slow too allow memory reclaim before the desktop hangs.
The switch was from a physical swap partition on a disk to dynamic swap in RAM. Zram is used the same as a physical swap partition, but A) is much faster, and B) allows compression so the actual available swap is much more than the physical reserved space. (I estimate that 8G of zram can contain as much as 14G of compressed swap data.)
Additionally, by residing in ram it increases security since now forensics cannot track what may have been done by scanning swap after the computer has been powered off. A physical swap does not ever get erased, but only overwritten when needed. In contrast zram swap is gone as soon as power is removed.