No space left on ZRAM

Why I get sometimes a ‘There is no space left on the device’ with ZRAM enabled?
It does this after 50-60 days of uptime…

Because there have been enough changes to a ZRAM’ed dir that the maximum reserved RAM is reached. Stop+Start of ZRAM will sync to SD.
Eventually increase in /etc/ztab and pay special attention to the process in post #1 on OH upgrades (which quickly consume 300+ MB right away for Karaf cache).

So can I use sudo systemctl restart zram-config to sync everything back to the SD card?

That’s really useful, even on a daily basis…

In theory only. That would require to/enforce a shutdown of OH.

My only problem with this, what happens if after a 100 days of uptime the power goes down? Then everything is lost since that day?
Why it is needed for the whole partition to use this? Why not only use this for folders which are generated often (logs, cache, etc…). Or why it doesn’t write everything back to the SD after a predefined time?
Even writing everything back to the SD once a day is less wear than writing everything real time…
And no I can’t install an UPS because I don’t have space for it, and also don’t really need it because this only happens once a year or so…

Yes it is lost. But you misunderstood. It doesn’t use the whole partition.
Yes you could change the entry for /var/lib/openhab2 into subdirs for tmp,cache,jsondb,persistence,etc instead of a single parent one, but that’s cluttering memory use, and memory is the premium we’re trying to save on. The current solution is considered to be a good tradeoff.
There’s actually very little data stored in ZRAM that you cannot easily afford to lose, and this little you can and should cover by daily backups.

Online sync is not available. The tools we would need for that to work with OverlayFS do not exist.

Thanks for confirming and clarifing these!
Unfortunately at my weekend house I have a raspberry and only a raspberry, nothing else, so everything is a little bit complicated there. I don’t know if I should use ZRAM there (it caused more issues there yet…).

However one addition:

  • Would it be possible to include these recommended steps during openhab upgrade into openHabian?
    I mean if you select it, it should first check for an available update for openhab if yes, then stop zram, clean cache etc… so do everything automatically… I still sometimes forget these steps.

Assuming you have Internet, you could setup Amanda backup with AWS as the backup target.

I’m too afraid of breaking anything when automating this.
It’s complex and would need to work with all HW, OS also for non-ZRAM users, that’s why. Sorry.

Yes, this is what I’ll do I think.

Double-check dumpcycle and runspercycle parameter when you do so you don’t get a full dump every night which happens in some circumstances.