ZRAM is very efficiently compressing information in the RAM and creates a kind of the virtual SWAP device, which actualy do not takes physical space on yours SWAP partition.
It comes with a tradeoff of the a little bit perfomance that’s being taken to compress and unpack data. but ZRAM is active by default even on the android so it’s not hard to guess how little we’re paying for having more RAM out of nothing.
Install it.
sudo pacman -Syu zram-generator
Create config file
sudo nano /usr/lib/systemd/zram-generator.conf
Paste this in ctrl+shift+v in terminal or use gedit/kate isntead of nano:
Check with htop, you should have now a Swp parameter, or if you already had swap file, it’s size should increace on the same value as a RAM that you have.
If not, try to reboot.
Also you can check is it working by the other way -
sudo dmesg | grep zram
To prevent conflicts, Arch wiki recommending to disable zswap, so lets do it. I have no idea why on wiki there’s no info that you can disable it in the grub.
sudo nano /etc/default/grub
In the line locate GRUB_CMDLINE_LINUX_DEFAULT add in the end zswap.enabled=0"
The difference compared to zram is that zswap works in conjunction with a swap device while zram is a swap device in RAM that does not require a backing swap device.
The question of “defaults” is rather tricky. What works for you might not work for others. Any distro (not just EndeavourOS) is most probably being run on a variety of hardware and for various use cases. Its not possible to ship such defaults that suit everyone.
For example,
this is probably a good configuration for you, it certainly is not suitable for my hardware or use case. Yes, the user can change it as per their preferences, but how many will actually change it?
While its won’t harm to ship some sane defaults, its better to stick to vanilla.
All this is personal opinion
That being said, thanks for the guide!
I can relate *running two virtual machines, while compiling applications on host and sending this message via Firefox on the same machine
erm this part didnt work for me: 1. grub-mkconfig -o /boot/grub/grub.cfg
/usr/bin/grub-mkconfig: line 265: /boot/grub/grub.cfg.new: No such file or directory
erm is this the dracut thing?
does anybody know how to update dracut one? Sorry if someone already posted it… I’m a noobbbb…
many thanks!
Priority
Each swap area has a priority, either high or low. The default
priority is low. Within the low-priority areas, newer areas are
even lower priority than older areas.
All priorities set with swapflags are high-priority, higher than
default. They may have any nonnegative value chosen by the
caller. Higher numbers mean higher priority.
Swap pages are allocated from areas in priority order, highest
priority first. For areas with different priorities, a higher-
priority area is exhausted before using a lower-priority area.
If two or more areas have the same priority, and it is the
highest priority available, pages are allocated on a round-robin
basis between them.
If you are not utilizing all your ram, you don’t need zram in the first place.
However, if your ram usage is shooting past 32gb, then zram will help. Keep in mind, if you make the zram size too large, it will probably backfire under higher load.
Because running out of RAM is problematic unless you are running an OOM killer. In most cases, it will result in a a hard freeze.
The answer that most people don’t like to hear is that there is not a simple “right answer”. Whether to use a swap partition, a swap file, zswap, zram, no swap or some combination depends on the individual’s workload and hardware.
I will say that using zram is actually a pretty good default for most desktop use cases.
So if I enable this, it will use all my ram as a compressed swap? Aproximately how much more ram space I will get out of this? 10%? Or more?
I have 14 gigs, and I had situations where it wasn’t enough and the system slowed down a lot, even with a nvme ssd. But I guess, I will still need a regular swapfile.
However an obligatory note : the config format has changed after I made the video. As usual, the new config too is “readable”. Rest of the steps remain same.