Conflicting ZRAM swap services?

I recently reinstalled Byzantium to my Librem 5. I am trying to us the Zramswap tool as explained here by Kyle Rankin, some years ago.

I would like to add more RAM and not necessarily have a larger SWAP file. I followed the instructions below:

Adding Extra RAM

Zram is a feature built into the Linux kernel that allows you to trade some CPU resources for RAM. With zram, you allocate a certain amount of your RAM for the purpose, and the kernel then transparently compresses that RAM on the fly using a fast compression algorithm. The result in my case is a system that looks and acts like it has 1.5Gb of extra RAM available as a swap partition, but one that is faster than using a local swap file.

To set this up, first I installed the zram-tools package. Then I edited the /etc/default/zramswap file to enable the compression algorithm that worked well on my Librem 5 and to tell it to use fifty percent of my available RAM as zram:

ALGO=lzoPERCENT=50

Then after a reboot (or just restarting the zramswap service), I had an extra 1.5Gb of RAM. Ever since I enabled zram I haven’t run into any Out of Memory Killer situations and the overall system including web browsing has worked well.

However, I get this error when trying to run the following:

zramswap start
<13>Sep 5 13:38:13 purism: Starting Zram
/usr/sbin/zramswap: line 53: /sys/block/zram0/comp_algorithm: Permission denied
<13>Sep 5 13:38:13 purism: Error: setting compression algo to lz4

Additionally, I get the below when I run:

purism@pureos:~$ zramswap status
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle 5.7G 4K 80B 12K 4 [SWAP]

I believe there are now conflicting ZRAM swap services and the image I installed doesn’t like the Kyle Rankin method of adding a bit extra RAM.

Is there a way to stop the current SWAP service and/or use the Zramswap service as suggested by Kyle Rankin?

1 Like

The article is outdated and not relevant anymore, zram is already configured by default and doing what you’re attempting to would actually reduce the available swap space.

1 Like

Thank you. I appreciate your response. However, I recall there appearing to be more RAM and not SWAP space. I am more concerned about the snappier performance caused by having more RAM than by being able to use many applications at one time.

Is there a way to disable the current (new) zram configuration so that I can go back to what I want to use?

2 Likes

That’s not how it works or ever worked. Zram is a compressed ramdisk, which can be used as a in-RAM swap space to effectively increase the available memory without resorting to on-disk swap. “Adding a bit more RAM” is just a metaphor for using swap on zram. The current default configuration is optimized for snappy performance, the one described in the article gives you the same thing, but less of it and with worse tuning parameters.

3 Likes

Even if it ever appeared that way, it has to be an illusion, right?

Possibly some confusion was caused by the free command which does show both actual RAM and swap space. (Hence the total of available memory would effectively go up if you subtracted some from actual RAM and added it back as compressed swap space, subject to the effectiveness of the compression algorithm.)

It is unclear that you will achieve snappier performance by having more RAM if it is only the illusion of more RAM. That would be a finely balanced calculation looking at how the gains that may (or may not be) achieved from a speed–space trade-off are offset by the overhead of compressing and decompressing. (I would also be personally concerned about battery depletion. It’s OK to run the CPU harder if you are on mains power such as might be the case if docked but if on battery power then that is another dimension to the trade-off.)

You will very likely achieve snappier performance if the Librem 5 was previously swapping to disk or otherwise using the disk to a greater extent.

All that said …

… that must surely have an answer. It’s your device and you are free to do that and anything else on it.

2 Likes

I

Ok, I understand and accept the superior knowledge each of you has on this subject.

However, I am not sure how to even try to use the alternate zram method that I was using, happily, before. Permission was denied to me to be able to use that method and I was hoping to get help to have the opportunity to turn it on or use the previous Rankin method. It appears I am being told that I am wrong and therefore permission to try the previous zram method is again denied. As such, I suppose I will need to resort to my previous neophyte methods to try and grant myself permission (or possibly break the device).

1 Like

I think there is a misunderstanding. I concluded with the exact opposite. Access Granted.

If you are worried about breaking your device, I suggest that you first use Jumpdrive to image the eMMC drive. So then you have a complete disk image to restore if things go pear-shaped. (Jumpdrive may also be useful to fix light stuff-ups. However for hard core stuff-ups, you will want a disk image to restore.)

2 Likes