How to download more RAM

tags: linux ram

Table of Contents

No, actually. We can do this by increasing our swap with Zram.

What exactly is Zram?

Zram basically takes a part of your actual physical ram and stores compressed ram contents in it. The gains are crazy

Why not just increase the swap directly?

Because regular swap is slower than Zram.

Setup

  1. Install zram-generator. On Archlinux, its

    pacman -S zram-generator
    
  2. Configure your /etc/systemd/zram-generator.conf

    [zram0  ]
    zram-size = ram * 2
    compression-algorithm = zstd
    swap-priority = 100
    fs-type = swap
    

    Now we just need to care about zram-size, it actually refers to the uncompressed size of Zram, not the compressed one, this means it will use a lot less of you actual physical ram. Please experiment with it until you find the sweet spot. For me it is 4 times the size of the ram. It works fine.

  3. Start Systemd service.

    systemctl daemon-reload
    systemctl start systemd-zram-setup@zram0.service 
    

    Note that you don't need to enable it. It will happen automatically upon reboot.

Author: tusharhero (tusharhero@sdf.org)

tusharhero's pages is licensed under CC BY-ND 4.0

Date:

Site built at: 2024-04-19 Fri 06:44

Emacs 30.0.50 (Org mode 9.6.15)