To end the discussion in the “show your desktop” about swap partition yes/no. I want to hear your thoughts about swap and why you use it or not.
Personally i have a system up and running with btrfs and 32GB of ram WITHOUT swap enabled. System runs very smooth compared to my Pop! OS install on the same notebook. I do notice improvements with Endeavour OS (like moving a window). So i really wonder what benefits a swap partition would have.
Pop OS uses zram + a swap partition. From my reading online this is not a great combo.
I did a test on a 13 years old notbook, enabled zram according to the arch wiki. I don’t see any benefits from it, only when you compile stuff it will use the swap.
I also would like to know how many amount of swap is needed for sample when you have 64gb of ram installed, how many do you add as swap or zram ? I don’t get a clear answer to that.
I truly don’t do things that need it with 32 GB, but I have zram enabled, and sometimes I see a few K in there ;0
Swap is mostly an idea from when machines didn’t have enough memory for their tasks. Someone with high utilization (like video processing multiples, compiling, etc) might need swap, but average desktop users of 16 GB or more probably don’t.
You will need a swapfile or partition for hibernation, if you choose to use it..the size of your memory.
It is a good idea to have some amount of swap of some kind. I have 64GB of RAM and without some swap I find that the oom killer will start killing applications at times.
This is not an answerable question. There is no set size. It all depends on your use.
Fedora only offers ZRAM. I disabled that and created a swap file on BTRFS some month ago. Arch Linux installation via archinstall also uses ZRAM when enabling it. I don’t know what is best for me. I prefer a separate partition like I get while installation of EndeavourOS.
I’m using 32 GB RAM and an 8 GB swap partition. On my laptop, I have 16 GB RAM installed and want to use hibernation mode. So I need a swap partition of minimum 16 GB.
I do understand that swap file and swap partition writes on disk while zram uses only memory.
I don’t want unnecessary writes on my Samsung 990 pro’s 4TB’s so i would use zram or nothing at all. But i don’t get a clear answer why swap is needed with that amount of ram (64GB).
Much of the technicalities of swapspace and how kernel handles memory management is above my head, but I gather that some amount of swapspace of some sort helps the kernel to free up some cache space for more frequently used pages by pushing those more rarely used pages into swap resulting in a better management of memory and better performance.
I am not sure if I have got it right but that’s about what I think I know which I also admit that it can be totally erroneous
I have 64GB or RAM in my system and I have 8GB of ZRAM set up, usually it is within 24-500KB, sometimes a few Megabytes-24MB, but there have been a few times where it reached 3.4GB usage.
I read in an old thread that some swap is always required regardless of RAM amount so I simply followed that advice. Do I need 8GB for ZRAM, I don’t really know, I originally set it to see what the largest amount I would use would be so I guess I could reduce it to 4GB. It could be a lot but I have been fine so far and my RAM usage is always around 60% every day, but the ZRAM usage varies depending on what I am doing.
As @dalto pointed out below, this depends heavily on your use case, and there are no hard and fast rules. As a rough guide, however, here’s the list I found online:
I have seen this option in zram-generator.conf but I have never looked into it. It seems to be a measure for Zram to write the incompressible pages into a storage device to free up space in memory.
writeback-device=
Write incompressible pages, for which no gain was achieved, to the specified device under memory pressure. This corresponds to the /sys/block/zramX/backing_dev parameter.
Takes a path to a block device, like /dev/disk/by-partuuid/2d54ffa0-01 or /dev/zvol/tarta-zoot/swap-writeback.
If unset, none is used, and incompressible pages are kept in RAM.
I guess if someone wants to use zram, it won’t hurt to add a little chunk of disk space for this purpose.
I just switched to zram last week (32GB RAM, 16GB zram). I tend to have at least virtual machine running (16GB used with Windows 11, usually) or a game, so my zram tends to get used quite a bit. I have not setup a writeback device yet, kinda waiting to see how this goes over a month or 2. So far the performance is good.
When I get my extra 32GB RAM next month, I don’t think the writeback device will be necessary.
The differences sound minute. Like variations on a theme–just different ways to do the same thing.
–Do I have this right?
OR?
Are all these different memory swaps for different applications? I.E. gamers, laptop owners, people who adore suspend and hibernate, people who are app-heavy to begin with, etc?
I’ve noticed faster load times of heavy-resource apps, like games and VMs. For example, my system right now has the following memory load:
$ free --mega
total used free shared buff/cache available
Mem: 33445 11751 13120 508 11100 21694
Swap: 16722 4533 12188
If I start my Windows 11 VM, my system barely blinks. This was not the case before, even though I set the swap priority very low (vm.swappiness = 10), whereas my zram settings are much higher:
Seems like I’m kind of an outsider here by using a swapfile with zswap on all my systems (baremetal and vms).
On the more memory constrained ones I see regular use of zswap. System performance seems mostly untangered in this state, although I did no actual performance tests .
The system will use (z)swap to remove unused data from memory to free it up for caches/buffers. So i guess it’s good to have atleast some swap, but i don’t know much about the actual memory management of the linux kernel, so this is just a wild guess.