ecdye / zram-config

A complete zram-config utility for swap, directories, and logs to reduce SD, NAND and eMMC block wear.
MIT License
412 stars 53 forks source link

Allow sync to persistent storage #79

Closed ecdye closed 2 years ago

ecdye commented 2 years ago

Using the same merge functionality in overlayfs-tools already used to write changes to persistent storage it is possible to write changes to disk without completely reseting the zram device. This allows for a quick sync to persistent storage to be run whenever desired.

Without the ability to sync, any changes made to the underlying filesystem will be lost if there was a sudden power loss or system shutdown. This can be mitigated by periodically running the sync command which will write the changes to persistent storage ensuring that the data will not be lost if anything goes wrong.

A default service that runs the sync every night is included in this change, however, it is not installed by default.

Fixes #72

Signed-off-by: Ethan Dye mrtops03@gmail.com

mstormi commented 2 years ago

Just wanted to ask you about syncing now seeing you have already implemented it ? Hadn't seen that earlier. Great ! How much testing did you do ? Is this ready for deployment in openHABian or is (lazy) unmounting impossible with OH running ?

ecdye commented 2 years ago

Just wanted to ask you about syncing now seeing you have already implemented it ? Hadn't seen that earlier.

Yeah, I just got that implemented about a week ago.

How much testing did you do ?

Not a ton, however it is using the exact same procedure as when we stop zram-config. The only difference is instead of cleaning up after the overlay merge we remount the overlay filesystem and keep going.

Is this ready for deployment in openHABian or is (lazy) unmounting impossible with OH running ?

Still impossible, as it would cause broken writes the sync still would require stopping openHAB or for that matter any service or program accessing the directory in zram before the merge and the restarting it after. It is merely a simpler way to merge changes than completely stopping zram and restarting it. It could be deployed but I have left it as an optional install here and would probably recommend doing the same there as well. As a side not because of the way I have implemented the sync, there would be no need to manually stop openHAB's services as I use the same custom service identification code that I do in the stop functionality to achieve the service stopping.