Since updating to OH4 I face an issue with mapDB, i.e. after cold reboot of the Raspberry (i.e. when e.g. electricity was lost), mapDB does not load the values anymore onStartUp, although I see in the folder /var/lib/openhab/persistence/mapdb that files seem to get updated
openhabian@openhabian:/var/lib/openhab/persistence/mapdb $ ls -l
total 248
-rwxr-xr-x 1 openhab openhab 32 Mar 3 20:40 Readme.txt
-rw-r--r-- 1 openhab openhab 33008 Mar 24 09:51 storage.mapdb
-rw-r--r-- 1 openhab openhab 192592 Mar 24 09:51 storage.mapdb.p
-rw-r--r-- 1 openhab openhab 16 Mar 24 09:51 storage.mapdb.t
my persistence file mapdb.persist looks like this:
The persistence folder is located / overlayed by zram.
That means persisted items are stored in zram.
In case of a power outage the power is lost immediately and zram content is not stored on the SD disk.
After a turning on the power again latest values cannot be restored as they are not available on the disk. Those values that are available on disk from last restart ( with clean shutdown procedure ) will be restored.
@Wolfgang_S : Thank you very much for the swift reply.
However, what I don’t understand is that not the lastest update is loaded, my strategy is that mapDB stores at everyUpdate. With version 3.x of OH this seemed to work, I never had this issue. Or do you I understand something not correctly?
ZRAM is an overlay filesystem to minimize write cycles to the SD card.
At boot time values from SD card are ‘copied’ into the overlayed ZRAM file system.
These values are restored during startup of OH.
Every new update is written into the ( overlayed ) ZRAM filesystem.
If the Pi runs through a clean reboot or shutdown process values from ZRAM are stored/written on SD card again.
If the Pi is “turned off” by removing the power plug or due to a power outage/loss content of ZRAM will not be copied to the SD card and previous stored values on SD card will be copied into ZRAM on the next power on / boot cycle.
@Wolfgang_S: Thank you very much Wolfgang that you take the time to explain the zram concept to me…
As I described I did not have this behavior in earlier versions of OH. Could that mean that the zram procedure was not active by then?
In my configuration and usage of OH it is important that even after power outage latest updated data is reloaded after a cold reboot. I have a HD and not an SD (with wearing off issues) so I don’t mind frequent writing on the HD. Is there a possibility to switch zram off and have a procedure where the updated data is peristed directly on the HD/SD insead of first to the RAM?