Setting up zRAM on Zorin OS

You will need to install some packages, first.

sudo apt install systemd-zram-generator

Next, you need to give it configuration:

sudo nano /etc/systemd/zram-generator.conf

That will open the terminal in a text editor. Copy this snippet below:

[zram0]
zram-size = ram / 2
compression-algorithm = zstd
swap-priority = 100

Then in your terminal window, either use ctl+shift+v to paste or use Mouse Right click - context menu and select paste.
Once the above is pasted in, tap
ctrl+o
That is the letter o, not a zero.
Then hit the enter key to save as current configuration.
Tap
ctrl+x to eXit the editor.
Then run:

Now, you must reload the daemon

sudo systemctl daemon-reload

Then start the service:

sudo systemctl start systemd-zram-setup@zram0.service

Verify with terminal command: zramctl and swapon --show.
Setting a higher swap priority makes the system use zRAM before the disk swap file.

4 Likes

7 posts were split to a new topic: Bandwagon Tangents

Thank you for sharing. I did this the other day, and no matter what when under x11 the system refuses to use the zram, but seems to use it in wayland.

This is odd. zRAM is a kernel function, so it should not matter at all if Wayland or X11.

Can you check in both protocol managers:

zramctl

swapon --show

1 Like

Well...

I just 'did the thing' & it seems to have worked...

Haven't restarted my computer but all seems fine...

I noticed swap mentioned in 'swapon --show' results - this makes me think that SSD swap IS being used(automatically)with this setup - & if that is true, I understand why I was advised/made to disable(¨killed" is what I saw after the fact)my swap before setting this up...

THANK YOU...=]

1 Like

Question on this. I did see this app, i did not think it will have a real world improvement. I haven't used it.

With my system running no swap, yes no swap, and still going well. I have my root (/) directory on my NVme and the /home directory on a spinning drive. Seeing storage is so very cheap in this day and age.

Will this app zRAM, make a real world difference? For example loading times, performance?

Thank you

No, I do not see any way it can.

It can help if your RAM is insufficient for the operating system and usage. But if your system is running fine - using this will not create any difference you would notice.
That is not its purpose - and there is nothing in how it is implemented that would create a performance boost in normal use.

Sorry it took a few days to reply. Here is what it shows when booted into Wayland.

zramctl
NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4             4G  288K   34K  368K         [SWAP]
name@comp-name:~$ swapon --show
NAME           TYPE      SIZE USED PRIO
/dev/nvme0n1p7 partition 5.6G   0B   -1
/dev/zram0     partition   4G 284K  100

I changed my logon name and computer name other than that that is verbatim.
I'll reboot into x11 and update this post or add a second one.

EDIT:
X11

zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4             4G   4K   69B   20K         [SWAP]
name@comp-name:~$ swapon --show
NAME           TYPE      SIZE USED PRIO
/dev/nvme0n1p7 partition 5.6G   0B   -1
/dev/zram0     partition   4G   0B  100

It always shows zero for both swap and zram on x11 and x11 will slow way down after running for a day or two, but Wayland doesn't , but has issues with NVIDIA, services sometimes.

I should have added, that I used "ram /2 4096" and "lz4" vs what you posted, but I did mine before I saw your right-up.

I am running a laptop with a 17.3 in monitor, a 10870H, 32 gigs of 3200/c22 RAM @2933, RTX 3060 6 gigs dedicated on open driver 595.99.02, and drives are both NVMe: WD_BLACK SN770 2TB and PNY CS3030 1TB SSD, kernel 7.0.0-38-generic.

A few points:
You are best to not use zRAM and Swap at the same time.

Use one or use the other.

The second is; these actions are completely independent of the Desktop PRotocol.
So, whether you are on Wayland or X11 will make no difference in this, at all.

And this shows in your output; You are using 0 of the swap.

A slowdown observable on GNome when using X11 makes sense, and has nothing to do with RAM, really. It has to do with Gnome, and that Gnome is cutting X11 and pushing for Wayland only. Gnome is no longer optimized on X11.

2 Likes

Thank you for the helpful information.
I didn't know if I should have gotten rid of the swap or not so I just dropped it's priority way down. I have a long way to go in learning the ins and outs of Linux. I used to spend days gutting Windows and customizing it ridding it of MS's junk, but I had to just give up on their AI slop. After years of playing with different distros, I finally decided to move over to Linux as my primary OS. That's what I mean by I have a long way to go and a lot to learn.

For zRAM users under liquorix, it's time to update your kernel

linux-liquorix (7.2-18)

  • apply optimizations for zswap and zram
    zram: use a singleton compression context for recompression
    zram: split zcomp into separate R/W streams
    zram: reset writeback state in zram_reset_device()
    zram: zstd: do not use kvzalloc() for zstd allocations
    zram: lz4hc: use LZ4_decompress_safe_usingDict()
    zram: lz4: use LZ4_decompress_safe_usingDict()
    zram: lz4hc: pre-initialize dictionary stream in setup_params
    zram: zstd: do not allocate empty C/D-dictionaries
    zram: remove debugfs entry on init failure
    zram: prefix backends printk-s
    zram: convert to SG-list zsmalloc object read API
    zram: add pr_fmt to backend files
    zram: do not release zstd global params from error paths
    mm: zswap: use stack requests for synchronous decompression
    mm: zswap: use separate compression and decompression requests
    • update version to 7.2.10-2

Please find here a YT tutorial about zRAM (also demarcation zswap and swaping). It shows deeply insides using the terminal.

It is in german, but just get your own language with
Settings- Subtitle - Automaticly translated