This is a step by step tutorial shows how to enable zram Kernel module and use as Swap device for better system performance in Ubuntu 24.04 PC/laptop with limited RAM.
As you may know, Ubuntu usually includes a swap space. It works like MS Windows’ “virtual memory”, that uses the hard disk for additional memory when there is not enough physical RAM for all tasks request.
Swap on disk however is slow, which will slow down the overall system performance. So, Linux introduced “zram” and “zswap” kernel modules to improve performance for computers with small amount of RAM.
This tutorial shows how to enable zswap kernel module to increase usable RAM in your Ubuntu computer or laptop.
As you know, Ubuntu Linux usually includes a swap space (either disk partition or swap file) on the disk. It can be used for hibernation, and as extended memory space. When the system needs more memory resources and the RAM is going full, then the inactive pages in memory are moved to the swap space.
Swap space can be helpful for computers with limited RAM. But, it’s slow! Too much swap in use will slow down the overall system performance.
As workarounds, Linux includes 2 kernel modules: zram and zswap. Instead of moving inactive pages from memory to disk (swap space), they do similar things by compressing the data into dynamically allocated RAM space.
As the data is compressed, it takes less physical memory space which makes your RAM even more usable. While, keeping the system running smoothly because reading from compressed data in RAM is usually faster than reading from swap on disk.
There are a variety of ways to improve your Firefox browser’s page load times. If you have a lot of RAM to spare in Ubuntu, moving Cache to RAM can speed up Firefox since computer can access data in RAM much faster than on a hard drive.
Firefox has a built-in feature that uses the browser cache in memory instead of disk. Below I’ll you how to enable it:
1. In address bar of Firefox, type in about:config and hit Enter. Click the button says “I’ll be careful, I promise!” to pass the warning page.
2. Stop Firefox from caching to disk.
In the filter bar, type in browser.cache.disk.enable. Double-click on the result line to set value to false.
3. Enable cache to RAM and assign cache size.
To enable cache to RAM, type “browser.cache.memory.enable” in the filter bar and make sure the value of result preference is true!
To assign cache size, create a new preference:
right click on blank area -> select “New” -> Integer
type in name “browser.cache.memory.capacity” (without quotes)
type in a value, number in KB (for example, 100000 means 100,000KB or 100MB). You can set the value to -1 to tell Firefox to dynamically determine the cache size.
When everything’s done, restart Firefox and check out the cache information by going to the about:cache page.