How to know if Zram is working?

If you want to see how your swap is being used you could use stress-ng.

stress-ng --vm 3 --vm-bytes 100% -t 10m

And see in the system monitor of your choice how the memory is eaten up and swap use kicks in.

Today after turning my PC on I see finally 0.09GB as used for Swap and I’ve been using my Web browser for almost 30 min only, I suppose everything is working fine fine with Zram. Could it mean zramd fails with my OS?

What command line did you run to show this result?

The swap usage could be in your RAM and confusing you.

$ swapon --show
NAME       TYPE      SIZE  USED PRIO
/dev/zram0 partition 7.8G 94.5M  100

With zramd I had 0.0GB used almost always, but with zram-generator I have something being used by during almost 2 hours, I’ll be monitoring it during the whole day.

zramd is not maintained over 2 years, it wouldn’t work with your current Kernel or your configuration would be missing.

configuration file is located at /etc/default/zramd

Readme: https://github.com/maximumadmin/zramd

I don’t use zramd, but please cite your evidence for these assertations.

It just sets up a zram swap device. While it has not been updated for 2 years, if it does its job correctly, there’s not much need to update anything.

It is currently cited as a viable method to set up a swap device in the Arch wiki.

Why would it not work with a current kernel? Why would the configuration be missing?

1 Like

Just out of curiosity, what is the content of its config file /etc/default/zramd?

Edit:

@Stagger_Lee

I am sorry to bother. I missed:

:eyeglasses:

1 Like

You can see it on github.

Here it is:

# See available algorithms by running "cat /sys/block/zramX/comp_algorithm"
# ALGORITHM=zstd

# Max fraction of physical memory to use
# FRACTION=1.0

# Max total swap size in MB
# MAX_SIZE=8192

# Number of zram devices to create
# NUM_DEVICES=1

# Swap priority
# PRIORITY=100

# Skip initialization if running inside a virtual machine
# SKIP_VM=false

I just installed zramd on a Virtualbox VM (running EndeavourOS).

Installed it and enabled the service. It works fine.

2 Likes

Thanks!

1 Like

I don’t use any zram either. But that was my guess without test.

After your testing, It works fine in your VM. Could you explain to @locuaz why it didn’t work for him?

If he did not stress the machine to specifically test it, then there’s no reliable data that shows that it wasn’t working. It looks like it was working on his computer, it just had not been utilized.

Perhaps he has also changed his swappiness value. Perhaps he simply did not stress his computer enough.

I try to install stress-ng but I’m getting errors

$ yay -S stress-ng
AUR Explicit (1): stress-ng-0.15.08-1
Sync Dependency (3): apparmor-3.1.4-1, judy-1.0.5-7, lksctp-tools-1.0.19-1
:: (1/1) Downloaded PKGBUILD: stress-ng
  1 stress-ng                        (Build Files Exist)
==> Packages to cleanBuild?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> 
  1 stress-ng                        (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> 
==> Making package: stress-ng 0.15.08-1 (Tue Jun 13 14:48:08 2023)
==> Retrieving sources...
  -> Downloading stress-ng-0.15.08.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 3749k    0 3749k    0     0  2094k      0 --:--:--  0:00:01 --:--:-- 3595k
==> Validating source files with b2sums...
    stress-ng-0.15.08.tar.gz ... Passed
:: (1/1) Parsing SRCINFO: stress-ng
[sudo] password for user: 
}resolving dependencies...
looking for conflicting packages...

Package (3)         New Version  Net Change  Download Size

extra/apparmor      3.1.4-1        4.26 MiB       1.18 MiB
extra/judy          1.0.5-7        0.58 MiB       0.14 MiB
extra/lksctp-tools  1.0.19-1       0.31 MiB       0.08 MiB

Total Download Size:   1.40 MiB
Total Installed Size:  5.16 MiB

:: Proceed with installation? [Y/n] 
:: Retrieving packages...
 lksctp-tools-1.0.19-1-x86_64                                                        84.3 KiB  54.6 KiB/s 00:02 [-------------------------------------------------------------------] 100%
 judy-1.0.5-7-x86_64                                                                140.0 KiB  81.4 KiB/s 00:02 [-------------------------------------------------------------------] 100%
 apparmor-3.1.4-1-x86_64.pkg.tar.zst failed to download
 Total (3/3)                                                                       1436.3 KiB  95.0 KiB/s 00:15 [-------------------------------------------------------------------] 100%
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from mirror.f4st.host : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from mirror.cspacehostings.com : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from mirrors.neusoft.edu.cn : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from mirror.pseudoform.org : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from asia.mirror.pkgbuild.com : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from sydney.mirror.pkgbuild.com : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from mirror.telepoint.bg : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from mirror.spaceint.fr : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from seoul.mirror.pkgbuild.com : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from europe.mirror.pkgbuild.com : The requested URL returned error: 404
error: failed retrieving file 'apparmor-3.1.4-1-x86_64.pkg.tar.zst' from geo.mirror.pkgbuild.com : The requested URL returned error: 404
warning: failed to retrieve some files
error: failed to commit transaction (failed to retrieve some files)
Errors occurred, no packages were upgraded.
error: could not set install reason for package apparmor (could not find or read package)
error: could not set install reason for package judy (could not find or read package)
error: could not set install reason for package lksctp-tools (could not find or read package)
 -> Failed to install layer, rolling up to next layer.error:error installing repo packages
resolving dependencies...
looking for conflicting packages...

Package (3)         New Version  Net Change  Download Size

extra/apparmor      3.1.4-1        4.26 MiB       1.18 MiB
extra/judy          1.0.5-7        0.58 MiB               
extra/lksctp-tools  1.0.19-1       0.31 MiB               

Total Download Size:   1.18 MiB
Total Installed Size:  5.16 MiB

:: Proceed with installation? [Y/n] n
error: could not set install reason for package apparmor (could not find or read package)
error: could not set install reason for package judy (could not find or read package)
error: could not set install reason for package lksctp-tools (could not find or read package)
 -> error installing repo packages
error installing repo packages

This version is obsolete. apparmor 3.1.5-1 is the current version. Looks like your package info is wrong.

Try to do a refresh first with yay -Syy

sudo pacman -Syu worked for me

During installation of stress-ng Swap was used 0.12GB (of 7.63GB)

After running stress-ng --vm 3 --vm-bytes 100% -t 10m I got these results:

stress-ng: info:  [30713] setting to a 600 second (10 mins, 0.00 secs) run per stressor
stress-ng: info:  [30713] dispatching hogs: 3 vm
stress-ng: info:  [30713] passed: 3: vm (3)
stress-ng: info:  [30713] failed: 0
stress-ng: info:  [30713] skipped: 0
stress-ng: info:  [30713] successful run completed in 600.51s (10 mins, 0.51 secs)

During that time I noted:

  1. my RAM (16GB) was being used up to 80%
  2. Zram remained at the same amount (0.12GB/7.63GB or ~2%) except for a couple of occasions where it briefly increased up to 4%

So the conclusion is my Zram is working fine, right? :smirk:

I suggest you use “top” or “htop” in a separate terminal to monitor memory and swap consumption. This will clearly tell you what swap is doing.
And you can even be more aggressive with stress-ng by using “--vm-bytes 110%

PS
And you can stop stress-ng at any time simply by pressing Control-C.

1 Like

I just updated my OS (~1GB) and after that Swap partition started to be used with changing values frequently, I had another problem with my monitor ultrawide (see this post) which was resolved with this great update. Therefore I think the anomaly with Zram was because incompatibility or bug of certain packages that were recently resolved. so I end this post.

Thanks for your help :+1:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.