fluidd-core / FluiddPI

FluiddPi - A Pi image with Klipper, Moonraker, Fluidd and Web Camera support pre-installed.
https://docs.fluidd.xyz
GNU General Public License v3.0
299 stars 58 forks source link

Read-Only filesystem? #33

Open ganzgustav22 opened 2 years ago

ganzgustav22 commented 2 years ago

Would you be interested in making the FluiddPi image a readonly filesystem? Would make things less error-prone on powerloss or people pulling the plug without shutting down and also not wear down the sdcard.

matmen commented 2 years ago

Hey, I like the idea of having the SD card more protected, but how would this work exactly? The log files, gcode files and moonraker database would still need to be written to the card and be persistent, so the same chance of corruption exists there, no? A PR to extend the lifetime of SD cards by writing the log files to a RAM FS is already there: https://github.com/fluidd-core/FluiddPI/pull/12

ganzgustav22 commented 2 years ago

There are two issues that are solved with a read-only system:

Yes, ideally everything should be on a ramfs. But having the logfiles on a ramfs instead of the sdcard is definitely a good start as it already reduces the amount of data written to sdcard by a large amount.

Different approaches are possible.

One could move everything to ramfs and only switch the sdcard to read-write and write the data to it when the user shuts down or restarts the system. Ofcourse then, on powerloss, everything since the last restart or shutdown would be gone. But the sdcard would be safe as it's read-only all the time.

Another option would be to sync the data in the ramfs to the sdcard in regular intervals (and only switch the sdcard to read-write during the syncing) but that would ofcourse bear the risk of corruption again if the user manages to kill the power in the wrong moment (i.e. during sync).

Yet another option would be to keep the sdcard read-only and only switch it to read-write when something actually has to be written. But that would only work for stuff like received gcode files or updates to the printer.cfg and the like (i.e. things that do not get changed/written too often), not for stuff like logs or the moonraker db which is more or less steadily written to.

I haven't looked at the details yet, but I think something like this could make sense:

I can give some help with making the base system read-only as I have already done that with Raspberry Pi OS.