I'm trying to build an onboard time lapse camera for my motorbike using a Pi Zero and a Pi camera powered by a USB port of my 5V 2.1A charger socket which has a on/off switch.
since I'd rather avoid another switch to power the Pi off before, can I use a read only file system for the sd and a usb stick to store the images?
this way I shouldn't damage the sd or the usb stick except in the rare case when I shut it down when is storing an image right?
but I could workaround this using a led that lights up for some second before the Pi takes an image.
or even better, can I achieve this by creating 2 partitions on the sd, a read only one for Raspbian and a read write one for image storing?
1 Answer
You can have read-only root FS and you can also borrow a trick from various "boot CDs" or live images like UnionFS. Having separate storage partition should be easy and you can fsck it and even reformat if fsck fails.
-
1so do you advice UnionFS with a read-only partition for the OS and a read-write partition for storing the images on the same sd? and powering it off suddenly in the worst case I'll get an image corrupted?– MikyApr 16, 2019 at 7:29
-
Yes, that's the idea. You can afford to call
sync
after writing an image you definitely have one corrupt file at most. Otherwise only what is not yetsync
-ed to the disk. You can run fsck at boot and even reformat the RW partition to make it "always work" if fsck fails... Logs, if needed, can be stored on the same or another RW partition. Apr 19, 2019 at 14:16 -
could the SD be damaged? what about using a read-only SD for the OS and a USB stick or USB SD adapter for image storing? it would be safer?– MikyApr 20, 2019 at 15:27
-
1Using USB stick is better and you may even get better IO speed. USB sticks (AFAIK) are also more durable, so it will last longer. This also will enable you to swap the sticks (but you have to handle it - discover the device, mount and/or format it...). Apr 23, 2019 at 12:37
-
1Ok I'll configure the SD as described here learn.adafruit.com/read-only-raspberry-pi/overview so that I can switch between read-only and read-write using a jumper, any advice on USB stick file system?– MikyApr 23, 2019 at 13:27