ZRAM generator file edits don't apply

I hope it isn’t a heresy to ask for help on other distros…

I’m fiddling around on a vmware 16 vm of Fedora 36 KDE and trying to edit zram-generator.conf file.

What i want to do with it is to have a 2048mb zram swap that can grow up to 8192mb depending on the load with zstd compression.

I have achieved zstd compression via making a text file named /etc/modules-load.d/zstd.conf and typing zstd .

Then I edited /usr/lib/systemd/zram-generator.conf file as below:

zram-size = 2048
max-zram-size = 8192
compression-algorithm = zstd

I have tried sudo systemctl daemon-reload and reboot to apply changes, however zram size does not change from the default installation. I have not been able to find a resource on fedora docs about this.

1 Like

I might be wrong but I have been under the impression that it is what the default configuration does anyways.
It get used as much as it is needed depending on the load or whatever there is that needs to be swapped out of RAM.

I think you would need to copy that file to /etc/systemd/zram-generator.conf and edit as you wish.

I think by default Fedora configures zram in /usr/lib/systemd, because I checked default paths of install from https://github.com/systemd/zram-generator but no other zram-generator file exists elsewhere.

image

Alright. But if you make the changes you want to that file, won’t they be overwritten with the defaults values in the event there is an update to the package zram-generator?

And also from the Github page:

Swap devices

Create /etc/systemd/zram-generator.conf:

/etc/systemd/zram-generator.conf
[zram0]
zram-size = ram / 2

https://github.com/systemd/zram-generator#swap-devices

The modifications done by the user under /etc will not be altered by up updates.

Also:

The zram† device, typically /dev/zram0, has a size set at create time during early boot, by zram-generator† per its configuration file. The memory used is not preallocated. It’s dynamically allocated and deallocated, on demand. Due to compression, a full /dev/zram0 uses half as much memory as its size.
https://fedoraproject.org/wiki/Changes/SwapOnZRAM

More digging:

/usr/lib/systemd/zram-generator.conf
/usr/local/lib/systemd/zram-generator.conf
/etc/systemd/zram-generator.conf
/run/systemd/zram-generator.conf

/usr/lib/systemd/zram-generator.conf.d/*.conf
/usr/local/lib/systemd/zram-generator.conf.d/*.conf
/etc/systemd/zram-generator.conf.d/*.conf
/run/systemd/zram-generator.conf.d/*.conf

https://github.com/systemd/zram-generator/blob/main/man/zram-generator.conf.md

https://docs.fedoraproject.org/en-US/fedora-coreos/sysconfig-configure-swaponzram/

1 Like

Sorry, no dice, zram device still on 3.9G disk size. Btw, if it makes any difference, vm is setup with 8gb of ram.

Not sure what the current “state of the affairs” is.

What are the changes you have done, to what and where?

I have done

sudo mv /usr/lib/systemd/zram-generator.conf /etc/systemd/

within the file also tried zram-size = ram / 8 (instead of = 2048)

But haven’t been able to find zram-generator.conf.d/*.conf file.

cp would have been the appropriate thing. Copying not moving.

These would need to be created:

A directory called zram-generator.conf.d in /etc/systemd
A file Given_Name.conf inside this directory.

Is that 1/8 of the size of your RAM?

@Bancerk

From my Fedora36 system:

$ inxi -S
System:
Kernel: 5.17.11-300.fc36.x86_64 arch: x86_64 bits: 64
Desktop: GNOME v: 42.1 Distro: Fedora release 36 (Thirty Six)

zram0 device configured by default to be half the size of RAM, that is 8 G.

sudo mkdir /etc/systemd/zram-generator.conf.d
sudo touch /etc/systemd/zram-genertor.conf.d/zram.conf
sudo nano /etc/systemd/zram-genertor.conf.d/zram.conf

content:

[zram0]
zram-size= 4096

save the file. Reboot.

sudo swapon -s 

Filename				Type		Size		Used		Priority
/dev/zram0              partition	4194300		0		100

I was able to find a solution as well:

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

[zram0] ← was missing this at first, lol
host-memory-limit = 8192
zram-size= min(ram / 4, 2048)
compression-algorithm = zstd

Although, since the configuration measures sizes with Mebibytes (fuck you Hollywood for this creation) I have also tried converting my expected disk sizes from MB to MiB and tried rebooting but zram didn’t start up. Only with powers of 2 it generates correctly, but generates them in MiB, which kinda annoys me. :face_with_raised_eyebrow:

1 Like

Nice!
Glad you got it resolved!
:handshake:t5:

Thank you for the assistance, wouldn’t have made it otherwise. :partying_face:

1 Like

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