1

I made a little device that solves a specific task. It gets turned on and off by powering it up and down. Now I had a corrupted file system for the first time. That's why I'm thinking about a strategy to avoid it.

I read that making the PI read only will prevent data loss. Is that correct?

Also I thought it might be possible to have an extra partition that is just a small read write tmp storage. The idea is that this partition just gets formatted by the py whenever it is corrupted. Is that realistic or are there any pitfalls? Does this extra partition endanger the other read only partitions?

1
  • 2
    Yes, readonly is a good way to prevent dataloss. Use ram mounted /tmp for tmp files and seperate partition for files that can change, like images, maybe a file database or something where you know it wont shut down when you writing to it. Better yet, unmount the partition when the Shutdown process and remount the writeable on boot up, for added data integrity.
    – Piotr Kula
    Mar 24, 2014 at 19:13

1 Answer 1

1

I would caution against using RAM for /tmp, but otherwise, the advice you have seen so far appears sound.

Basically to create this correctly, you'll want to partition your SD card into several partitions, most of them mounted read-only, and the swap and /tmp (and probably also /var) mounted read-write. You may also want /home mounted read-write as well, but that depends on how you're using the RPi.

Setting up these filesystems is left as an exercise to the OP.

(I haven't checked this personally, but you might find a way using GPIO to signal the RPi that shutdown is imminent, perhaps using something like a rechargeable battery pack with a charge controller to power the RPi for long enough to shutdown gracefully once main power has been turned off.)

2
  • 1
    Thanks for the tips. Unfortunately I don't have any shutdown signal, because power just gets pulled. Since that device is running on batteries I want to cut the power after shutdown - but I don't want two switches for the user since non tech people will operate it. That's why I just let them "pull the plug" by pulling the cable. I hope read only partitions will help me to avoid fs corruption.
    – user13716
    Mar 30, 2014 at 1:46
  • I'd love to hear how the RO file system works for you!
    – WineSoaked
    Apr 12, 2014 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.