After that I typed sudo systemctl daemon-reload and sudo systemctl start /dev/zram0.
Depending on the instructions on the internet I now find different commands how to check if zram is running. Unfortunately the answers I get from the system are not clear for me.
lsblk shows me the zram0 device I also see /var/compressed.
swapon command gives me no output and free -h shows me the output enclosed
I am pretty sure that this is not correct. Where did you get this from?
Try this:
systemctl start systemd-zram-setup@zram0.service
and then check the status:
systemctl status systemd-zram-setup@zram0.service
EDIT:
I find your zram-generator.conf also pretty odd. If you want to use zram0 as swap you would not want to create it with btrfs filesystem. swap has its own filesystem.
For testing pruposes I suggest you start with a minimalistic zram-generator.conf like:
zram-generator provides a systemd-zram-setup@.service unit to automatically initialize zram devices without users needing to enable/start the template or its instances. See zram-generator(8) and zram-generator.conf(5).
For example, to create a zram swap device using zstd and half of the entire available ram, install zram-generator, then create /etc/systemd/zram-generator.conf with the following:
/etc/systemd/zram-generator.conf
[zram0]
zram-size = ram / 2
compression-algorithm = zstd
swap-priority = 100
fs-type = swap
Reboot, then check the swap status of your configured /dev/zramN devices by reading the unit status of the systemd-zram-setup@zramN.service instance(s), or by using zramctl(8).
Note:
zram-generator provides a systemd-zram-setup@.service unit to automatically initialize zram devices without users needing to enable/start the template or its instances
Try this: systemctl start systemd-zram-setup@zram0.service
and then check the status: systemctl status systemd-zram-setup@zram0.service
With this and the minimal config it has already worked that zram0 is shown up.
That with …sudo systemctl start /dev/zram0… I had from this forum post.
have then now tried line by line to test the config from my first post. But as soon as I enter one following lines* zram0 is gone again. So here seems to be a problem.
I had the lines from the example config “zram-generator.conf.example” and from https://github.com/systemd/zram-generator/blob/main/README.md
I “played around” with the following in zram-generator.conf:
[zram1]
# This section describes the settings for /dev/zram1.
#
# host-memory-limit is not specified, so this device will always be created.
# Size the device to a tenth of RAM.
zram-size = ram / 2
# The file system to put on the device. If not specified, ext2 will be used.
fs-type = ext2
# Where to mount the file system. If a mount point is not specified,
# the device will be initialized, but will not be used for anything.
mount-point = /run/compressed-mount-point