If you have used the Raspberry Pi mini PC for some time and on multiple projects you have probably inadvertently remove the power supply and corrupted the operating system contained on the SD card.
Once corrupted the SD card needs to be wiped and OS reinstalled together with any files that may have been on the Pi. The team over at Adafruit have now created a script to help keep your files safe from corruption even if the Raspberry Pi mini PC power is cut short.
Adafruit explains more :
Most microcontroller projects have an on/off switch or some quick way to cut power, while computers like the Raspberry Pi require an orderly shutdown procedure…otherwise the SD card may become corrupted and the system will no longer boot.
This is why we normally use the shutdown command: all those files are put away in a known valid state. But if power is unexpectedly cut, these lingering half-written files can render a card unbootable…one can try patching it up, but sometimes there’s no recourse but to wipe the card and reinstall everything.
The Solution. The script we provide here adapts Raspbian to work in a read-only mode. Temporary files are stored in RAM rather than on the SD card, making it more robust in this regard. You can just unplug the system when done. The tradeoff…as the read-only name implies…is that nothing can be written to the card in this state. Can’t install software, can’t record pictures. So it’s not the solution to every situation, but may be helpful with certain passive tasks.
To download the Raspberry Pi read only script jump over to the official Adafruit website via the link below. If you enjoy building Pi projects you might be interested in our comprehensive list of Raspberry Pi displays, HATS and small screens.