I’m a little bit unsotisfied about the ZRAM behaviur I expertice and I ask to the expert if is possible a workaround to have the possibility to restoreONstatup my enviroment.
My OpenHABian OS runs on a RaspberryPI 3+ with the usual SD card.
I read the dedicated posts and use ZRAM is higly couciled to prevent continous writing and reduce a lot the possibility of SD corruption (Am I right 'till now?)
I don’t have an UPS and to be honest I don’t want to buy one.
The very big problem I have is that sometimes, bacause of many causes, the raspberry reboots in the “deprecated” but very used = hardware shootdown the items restore on the last saved status (in my case the allarm was on = allarm on even if i’m at home)
My question is:
Is possible to force Zram to write the values on the SD card one at hour (for example)???
Well, you can force writes by stopping the zram-config service - but doing so will inevitably restart OH as well.
You could also take copies of mapdb yourself. But that, just like forcing writes, is just a bad hack
as you will never get back to the latest state for all items.
If you really experience outages that often, you really should be getting a UPS.
You will probably get up to date values on restore.
But you will severely put your system integrity at risk, of course.
Note that in addition to losing what ever is in zram, each and every time the RPi loses power you run the risk of corrupting your system. If the machine happens to be writing to the SD card when the power is lost, you lose not only that file but any file that happens to be sharing that sector of the card. With wear leveling that could be anything like parts of the kernel, file system tables, device drivers, etc.