Hi guys! I'm a bit tired that my system sometimes completely becomes unresponsive while running things that could fill up the memory. I have 32GB of RAM, a bit of a swap file in my SSD (I think something like 5GB swap), but this clearly isn't cutting it. I was having a few browser windows opened, a handbrake encoding that was paused and decided to open Death Stranding 2, which is optimized to take around 5-6GB of RAM. And the system became once more so unresponsive that I had to literally reset it, after 5mins of nothing. I'd like to implement in my Ubuntu-based distro what they have in CachyOS. I'm not exactly sure, but I think it's a ZRAM-based swap partition? Something like 1 or 2GB commited to compressed virtual memory in RAM? Seems this works much better when things are close to getting dicey...how would I go about doing what they use in CachyOS? Is there any easy to follow guide?

all 9 comments

sorted by: hot top controversial new old
[–] 8 points 5 months ago

a handbrake encoding that was paused and decided to open [a game]

Even in 2026 that does not seem like good practice to me.

Have you tried switching to a different tty and killing the handbrake process?

Also, have you checked that it's really RAM getting filled up that freezes your system?

  • source
  • [–] 7 points 5 months ago (4 children)

    Use systemd-zram-generator. The process is explain in the DebianWiki and the ArchWiki and this random blog, but it boils down to just a few commands you need to run:

    $ apt install systemd-zram-generator
    $ sudoedit /etc/systemd/zram-generator.conf
    [zram0]
    zram-size = min(ram, 8192)
    compression-algorithm = zstd
    $ sudo systemctl daemon-reload && sudo systemctl start systemd-zram-setup@zram0.service
    

    You can tweak the settings above. Fedora recommends using zram-size = min(ram, 8192), which would correspond to 8GB ZRAM in your case. CachyOS uses a less conservative config with zram-size = ram.

    To confirm that zram is working, run zramctl. It should print something like

    NAME       ALGORITHM DISKSIZE   DATA  COMPR  TOTAL STREAMS MOUNTPOINT
    /dev/zram0 zstd            8G 430.8M 137.6M 142.9M         [SWAP]
    

    See also Improving system responsiveness under low-memory conditions.

  • source
  • hideshow 4 child comments
  • [–] 3 points 4 months ago* (3 children)

    Systemd absorbed zram now.

    And no, you don't need a background service for this.

    # modprobe zram
    # zramctl /dev/zram0 --algorithm zstd --size "$(($(grep -Po 'MemTotal:\s*\K\d+' /proc/meminfo)/2))KiB"
    # mkswap -U clear /dev/zram0
    # swapon --discard --priority 100 /dev/zram0
    
  • source
  • parent
  • hideshow 3 child comments
  • [–] 2 points 4 months ago* (2 children)

    What happens when you reboot?

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 4 months ago (1 child)

    Using a udev rule

    The example below describes how to set up swap on zram automatically at boot with a single udev rule and an fstab entry. No additional packages are needed to make this work.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 5 points 5 months ago

    Try it. I have configured ZRAM on Linux Mint and Debian, works like a charm.

    If I may ask: why are you thinking of only committing 1 or 2GB to ZRAM? This way your net RAM capacity increase will only be a few hundred megs. I recommend to allocate 25% to 60% of your RAM to it.

    To set it up, I have used an LLM for instructions, so don't listen to me for derails. I recommend prompting/searching for instructions youryelf if others aren't aplble to point you to a guide.

  • source
  • [–] 2 points 4 months ago

    You might want to look into zswap as well.

  • source
  • [–] 1 point 4 months ago

    When your system starts swapping it will also start to crawl. Just set up an oom protector, then when you run out of ram, the system will kill the culprit automatically and your system will never crawl, and you get a notification what's happened and why.

  • source