Speed Up Your Linux System with Zram

Zram, https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html, is a Linux kernel module that creates a compressed block device in RAM. This device can be used as swap space or a general-purpose RAM disk. By compressing data in memory, zram allows your system to store more data in RAM, reducing the need to swap to slower disk storage and improving overall responsiveness.

In particular, zram

  • Increases effective RAM capacity by compressing data.
  • Reduces disk I/O and wear, especially useful on SSDs.
  • Improves performance on systems with limited memory.

If you’re looking to boost your Linux system’s performance, especially on machines with limited RAM, zram is a powerful tool worth exploring.

In this post, I’ll show how to set it up on both Arch Linux and Ubuntu.

Installing zram

On Arch Linux

Install the zram generator package:

On Ubuntu

Install the systemd zram generator:

Configuring zram

Create a configuration file to set up your zram device. For example, to allocate half of your system’s RAM to zram and use the efficient zstd compression algorithm, run:

After saving the configuration, reboot your system to activate zram.

By default, zram will have the precedence over an existing swap partition.

You can use the command zramctl to see the status of zram and swapon to show your swap partitions (zram’s one will be /dev/zram0).

4 thoughts on “Speed Up Your Linux System with Zram

  1. Jim Abernathy

    Thanks for the information. I’ve been using zram-tools on Debian systems and zram-generator on Arch systems. But I didn’t realize that zram-generator also was available on Debian systems.

    Reply
  2. Eq

    Wonderful and very useful article as always. On a completely different note is there any chance we get a small series exploring the go language? I have been experimenting with it and albeit a bit convoluted at times It Is quite a fantastic language.

    Reply
      1. Eq

        It certainly makes sense as you from what I can gather are very Deep on the Java ecosystem. In my biased experience I found go works great but I do not love oop heavy software architecture (besides your Metodologie di programmazione course!).
        Thanks for the kind reply (maybe When I Will have to write my thesis I wont propose something in go 😉 )

        Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.