Guide: How to Set Up Custom DNS for Google Sites
If you are using an older laptop or desktop computer with limited RAM (such as 2 GB, 4 GB, or even 8 GB), you have probably experienced your system slowing down or freezing when opening multiple browser tabs.
Instead of immediately buying new hardware, you can give your Ubuntu system an instant performance boost by enabling ZRAM.
Normally, when your computer runs out of physical RAM, Ubuntu moves overflow data to a swap file on your hard drive or SSD. Even on a fast SSD, reading and writing to disk is significantly slower than working directly in RAM—causing noticeable lag.
ZRAM solves this problem by creating a compressed block device directly inside your RAM.
Faster than Disk Swap: Data is compressed on the fly and kept inside your fast memory instead of being written to your slow hard drive.
More Effective Memory: Depending on the data, ZRAM can compress memory at roughly a 2:1 or 3:1 ratio—effectively giving a 4 GB RAM machine the breathing room of 6 GB or more.
Extends SSD Lifespan: Because your system writes far less swap data to your drive, it reduces wear and tear on older SSDs.
On modern Ubuntu releases like Ubuntu 24.04 LTS, systemd-zram-generator is the cleanest, most modern, and most stable way to configure ZRAM. It integrates directly into systemd and sets up compressed memory at boot without legacy scripts.
Open your terminal (Ctrl + Alt + T) and install the generator package:
Create a configuration file at /etc/systemd/zram-generator.conf using Nano:
Paste the following recommended configuration into the file:
zram-size = ram / 2: Allocates up to 50% of your physical RAM for compressed ZRAM swap (you can also use ram for 100% on 2 GB–4 GB machines).
compression-algorithm = zstd: Uses zstd, which offers the best balance between high compression ratio and fast CPU speed.
swap-priority = 100: Ensures Ubuntu always uses fast ZRAM before touching your slower disk swap file.
Save the file by pressing Ctrl + O, hit Enter, and exit Nano with Ctrl + X.
Reload systemd and start your new ZRAM swap device immediately without even needing a full reboot:
If you are using an older Ubuntu version or want a completely zero-configuration setup that handles everything automatically out of the box, you can install zram-config (or zram-tools):
After running the command, simply reboot your PC (sudo reboot) to activate ZRAM.
Regardless of which method you chose, you can verify that ZRAM is active by running:
If everything is set up properly, you will see /dev/zram0 listed with a high priority (100), confirming that compressed RAM swap is actively protecting your system from slowdowns.