Are people on this forum using zramswap, and if so, what is the recommended setup?
I gave it a go, but get errors:
purism@pureos:~$ systemctl status zramswap.service
â—Ź zramswap.service - Linux zramswap setup
Loaded: loaded (/lib/systemd/system/zramswap.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2021-10-20 14:18:28 CEST; 47s ago
Docs: man:zramswap(8)
Process: 695 ExecStart=/usr/sbin/zramswap start (code=exited, status=1/FAILURE)
Main PID: 695 (code=exited, status=1/FAILURE)
CPU: 45ms
okt 20 14:18:28 pureos systemd[1]: Starting Linux zramswap setup...
okt 20 14:18:28 pureos zramswap[695]: /usr/sbin/zramswap: rad 53: echo: skrivfel: Ogiltigt argument
okt 20 14:18:28 pureos root[743]: Error: setting compression algo to lz4
okt 20 14:18:28 pureos zramswap[743]: <13>Oct 20 14:18:28 root: Error: setting compression algo to lz4
okt 20 14:18:28 pureos systemd[1]: zramswap.service: Main process exited, code=exited, status=1/FAILURE
okt 20 14:18:28 pureos systemd[1]: zramswap.service: Failed with result 'exit-code'.
okt 20 14:18:28 pureos systemd[1]: Failed to start Linux zramswap setup.
Contents of /etc/default/zramswap:
# Compression algorithm selection
# speed: lz4 > zstd > lzo
# compression: zstd > lzo > lz4
# This is not inclusive of all that is available in latest kernels
# See /sys/block/zram0/comp_algorithm (when zram module is loaded) to see
# what is currently set and available for your kernel[1]
# [1] https://github.com/torvalds/linux/blob/master/Documentation/blockdev/zram.txt#L86
#ALGO=lz4
# Specifies the amount of RAM that should be used for zram
# based on a percentage the total amount of available memory
# This takes precedence and overrides SIZE below
PERCENT=50
# Specifies a static amount of RAM that should be used for
# the ZRAM devices, this is in MiB
#SIZE=256
# Specifies the priority for the swap devices, see swapon(2)
# for more details. Higher number = higher priority
# This should probably be higher than hdd/ssd swaps.
PRIORITY=100
I am getting the error with the compression algo, but no idea how to fix it.
/usr/sbin/zramswap: rad 53: echo: skrivfel: Ogiltigt argument
Near as I can make out, that translates to
line 53: echo: write error: invalid argument
I would guess that it is attempting to write to /sys/block/zram0/comp_algorithm
(using the echo
command) in order to set the compression algorithm. zram0
might be some other number e.g. zram1
.
Several things could be going wrong e.g. the desired zram device doesn’t even exist or e.g. it does exist but lz4 is not a supported compression algorithm.
So I would start with ls -l /sys/block/zram*
If comp_algorithm
exists then cat
it to see what it might currently be set to.
If the binary zramctl
exists then run it to see what output it gives.
If still no insight, edit /etc/default/zramswap
to try at least the other two options for compression algorithm that it suggests might exist.
I fear that you need to reboot after any change, so playing with this will be time-consuming.
It turned out that my /sys/block/zram0/comp_algorithm
was corrupt. I purged and reinstalled zram-tools and then edited /etc/default/zramswap
like this:
# Compression algorithm selection
# speed: lz4 > zstd > lzo
# compression: zstd > lzo > lz4
# This is not inclusive of all that is available in latest kernels
# See /sys/block/zram0/comp_algorithm (when zram module is loaded) to see
# what is currently set and available for your kernel[1]
# [1] https://github.com/torvalds/linux/blob/master/Documentation/blockdev/zram.txt#L86
#ALGO=lz4
ALGO=lzo
# Specifies the amount of RAM that should be used for zram
# based on a percentage the total amount of available memory
# This takes precedence and overrides SIZE below
PERCENT=50
# Specifies a static amount of RAM that should be used for
# the ZRAM devices, this is in MiB
#SIZE=256
# Specifies the priority for the swap devices, see swapon(2)
# for more details. Higher number = higher priority
# This should probably be higher than hdd/ssd swaps.
PRIORITY=100
which gives me this:
purism@pureos:~$ swapon -status
Filename Type Size Used Priority
/dev/zram0 partition 1531668 0 100
I will evaluate these settings and see if I get any performance improvements.