Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-Only filesystem? #33

Open
ganzgustav22 opened this issue Apr 20, 2022 · 2 comments
Open

Read-Only filesystem? #33

ganzgustav22 opened this issue Apr 20, 2022 · 2 comments
Labels
FR - Enhancement New feature or request

Comments

@ganzgustav22
Copy link

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 matmen added the FR - Enhancement New feature or request label Apr 20, 2022
@matmen
Copy link
Member

matmen commented Apr 20, 2022

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: #12

@ganzgustav22
Copy link
Author

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

  • Data corruption on powerloss
  • sdcard wear due to more or less constant writing of lots of data

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:

  • Make / and /boot read-only by default
  • Write logfiles to ramfs, don't do any syncing on them, if a powerloss occurs they're gone and that's it
  • Write gcode files as they come in, maybe even to a different partition (so that / and /boot can be kept read-only)
  • Write config files as they are changed
  • Moonraker db I'm not sure about, does it also contain data that needs to be persistent?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FR - Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants