Introduction
This is a feature of Raspbian/Raspberry Pi OS that I don't think gets enough attention: The ability to put the entire SD card in read only mode.
This is good for a couple of reasons: * If the raspberry pi is powered off unexpectedly (someone removes the power cord) it won't corrupt your system * It reduces wear on the SD card, increasing the life of your system
This second one is the appealing one to me, although both have thier cases. I have a number of Raspberry Pis round the house that run an application 24/7 and don't need to write anything to disk (except maybe logs). Under normal circumstances, the logs from my application and other system logs will be written to the SD card...and over time the flash in the SD card will wear out. This is annoying.
The "Overlay File System" in Raspbain fixes this. It puts the SD card in a read only mode, and overlays your filesystems with some form of RAM filesystem. This means anything that is written while in this mode will be gone/lost on a system reboot. Not useful for all applications, but very useful for others.
To enable this, follow the following instructions:
- Open up a terminal
sudo raspi-config
- Choose "4 Performace Options"
- Choose "P3 Overlay File System"
- Answer "Yes" to "Would you like the overlay file system to be enabled?"
- "OK"
- Answer "Yes" to "Would you like the boot partition to be write-protected?"
- "OK"
- Choose "Finish"
- Answer "Yes" to "Would you like to reboot now?"
After the reboot, anything you write to the filesystem will be gone after a restart - give it a try!