Reading time: 2 – 2 minutes
Two years ago I wrote an article discussing how to set up OpenWRT filesystem configuration for controlling writes in the flash card: Raspberry PI and OpenWRT flash partition proposal and rescue boot support for embedded systems.
This current article is mainly for referencing a very good article about how to work with Raspbian with a read-only filesystem and share a fast and dirty cookbook about how to play with that. First of all the reference to: Protect your Raspberry PI SD card, use Read-Only filesystem.
My cookbook about how to get the essence of that article is simple, locate in your /etc/fstab file the line:
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
and modify that line with:
/dev/mmcblk0p2 / ext4 defaults,noatime,ro 0 1
After rebooting your system is going to work in read-only mode. I don’t remember if I modified anything else of the booting process but I don’t thing so.
Because sometimes I have to modify anything in the flash card, I added the next two lines in the ~/.bashrc file:
alias rw='sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot'
alias ro='sudo mount -o remount,ro / ; sudo mount -o remount,ro /boot'
Now just with the command rw it’s really easy to get the root filesystem in the write mode, and when I finish my updates just typing ro it’s go back to read-only mode.
I hope it’s useful for you.