Use log2ram for volatile files

Log2ram is a package out there that builds ram drives for highly volatile files (i.e. logs, db, etc…). Part of the package is writing the logs back to disk once a day (configurable via Cron).

Would there be interest in integrating this into the HestiaPi, with the interest of saving the SD card from dying an untimely death?

My opinion would be no, this isn’t a good idea for the HestiaPi, at least when running the default openHAB. The two biggest limiting factors are the single core CPU and RAM. There simply isn’t enough RAM so at some points, particularly when the machine is starting up, the swap gets used.

Moving the logs to RAM is going to decrease the amount of RAM available which will cause the swap partition to be used even more. I’d not be surprised if doing this would increase the number of writes to the SD card as a result, not reduce it.

ZRAM might be an option as it compresses the file system that’s in RAM letting one put more in there without consuming as much RAM. But then the fact that we have only a single CPU might slow everything down because the CPU has more to do. And even taking a little bit of RAM for logs is going to increase the use of the swap. You can look at the openHABian scripts for details on how to do it.

I think the best option is to just retain backups of your HestiaPi SD card, or at a minimum backups of any changes you’ve made to the configs. Unless and until HestiaPi switches to something with more RAM using tempfs/zram type partitions is not going to be an option. Note: I’m not necessarily advocating for this.

In the work I’ve done to improve the boot times and flexibility for users to modify the configs through the browser instead of editing files on the Pi itself, I’ve also modified the logging to greatly reduce the amount that gets logged to the SD card in the first place, at least from OH. It’s way low priority, but I also have plans to add a button to BasicUI to turn the logging on/off entirely to further reduce the writes. There isn’t much else writing to the SD card on the HestiaPi.