Raspberry Pi with read-only filesystem

AdaFruit has posted this script and information on making a read-only filesystem to eliminate possible issues if the power is disconnected from the Pi without doing a normal shutdown. https://learn.adafruit.com/read-only-raspberry-pi/

I have read through all of the threads here and opinions seem to be split whether or not just disconnecting the power has the POTENTIAL for issues. My experience is that it CAN cause issues and I have had a file system scrambled to where the Pi was rendered unbootable. Not the thing you want to have happen half way through the playoffs. But, YMMV.

We have considered using the Pi as a vision coprocessor in the past but didn’t do it due to possible corruption issues. I haven’t tried this information and script yet, but intend to ASAP.

Thought I would share for FWIW.

Thanks for posting this.

This is 100% a real world issue and file system corruption due to power loss is second only to physical media problems in the world of data storage.

This is not a complete solution, but our roborio robot app is setup to send a message (via network tables) to Raspberry pi which when received performs a shutdown of the raspberry pi. The message gets sent with 2 seconds left in a match. We needed this because the raspberry pi stores all vision processed video to file, and before we added this, sometimes the video would be corrupted. After we added this we never got corrupted game videos. The only downside is you need to power cycle the robot after every match.

That said I have power cycled Raspberry pi over a hundred times and not yet have I seen a corruption of the os itself.

Even so, we keep a backup micro sd card, just in case.

I think those steps are sufficient to avoid troubles.

The raspberry PI will eventually suffer a corruption issues that will render the file system unusable.

Our solution to this is as follows:

  1. The root and boot file systems should be configured as read only. There are various guides available to achieving this.
  2. There should be a read/write partition for logging/vision/temp data that is ext4 and read/write. The reason for ext4 is inbuilt filesystem logging to avoid corruption on power loss and read/write so we can write to it :slight_smile:
    The other choice for your data filesystem is vfat which WILL be corrupted, as we found from experience. unless you want the startup scripts to rebuild this file system on each boot and hope you can retrieve data afterwards.
  3. You should create a systemd startup script to start you process on boot, AND restart it on process failure. It is really annoying to have the script dying half way through a match and not restarting because of an unforeseen bug.

Now, an interesting ramification of this is that you cannot read the data filesystem directly on a windows PC.

I had excellent results with this tutorial…when I read it carefully. I used Raspbian Stretch 2017-11-29.

https://www.raspberrypi.org/forums/viewtopic.php?t=161416

Notably, some of the code boxes require you to scroll down.

Also, on one of the later pages of the thread, someone recommends setting the /boot partition to not auto-mount, which seems like a good idea. It’s easy enough to mount it as read/write when needed.

Changing from read-only to read/write is as easy as removing a statement in /boot/cmdline.txt and rebooting. Same for the reverse.

This is a tutorial I wrote last year for setting up one with a read-only filesystem as well as other miscellaneous configuration like turning off wifi, setting up fixed IPs, starting a program on boot, etc: Raspberry Pi 3 for FRC Configuration