Hi guys
I'm using my RPi V2 for an industrial application, where the device will undoubtedly be powered off at the main power socket without proper shutdown.
I plan to mount the Raspian Operating System on the SDCard as Read Only. This is sufficient for my dedicated application. I do however have some configuration files that need to be updated and also a small sqllite database that I will need to write to occasionally. I plan to have these files on a USB flash drive.
I realise that an abrupt power loss while writing to the files on the USB drive will cause corruption. I also realise that the flash drive will perform wear leveling operations which shift data around in the background, and a sudden power failure during this operation could corrupt the drive. I have to assume that the drive will not be removed during power state.
I'm running my RPi from a custom 24v to 5v power supply that I built on a daughter board. Experiment has shown that a 20,000uF capactitor can hold up the supply for 2 seconds after power fail. I can detect the loss of 24v power and signal to the RPi, my application then has 2 seconds to save any data and put itself in an orderly state.
Other experimentation has shown Writing a 3MB text file to USB Flash drive takes between 133 to 250msec on the Raspberry Pi. Following this with a drive dismount takes an additional 270 msecs. So we can write an open 3MB file and dismount the flash drive in about 400 to 500 msec. My application will never write anything larger than this to the Flash drive.
The way I see it is, a 2 second power failure warning allows time to save any necessary data to flash drive, dismount the drive and put my application in a tight loop before the power fails.
Am I missing anything here? What could go wrong? Is there anything in the Raspian OS that is going to spoil my plan?