Adafruit’s read-only Raspberry Pi

For passive projects such as point-of-sale displays, video loopers, and your upcoming Halloween builds, Adafruit have come up with a read-only solution for powering down your Raspberry Pi without endangering your SD card.

Adafruit read-only raspberry pi

Pulling the plug

At home, at a coding club, or at a Jam, you rarely need to pull the plug on your Raspberry Pi without going through the correct shutdown procedure. To ensure a long life for your SD card and its contents, you should always turn off you Pi by selecting the shutdown option from the menu. This way the Pi saves any temporary files to the card before relinquishing power.

Dramatic reconstruction

By pulling the plug while your OS is still running, you might corrupt these files, which could result in the Pi failing to boot up again. The only fix? Wipe the SD card clean and start over, waving goodbye to all files you didn’t back up.

Passive projects

But what if it’s not as easy as selecting shutdown, because your Raspberry Pi is embedded deep inside the belly of a project? Maybe you’ve hot-glued your Zero W into a pumpkin which is now screwed to the roof of your porch, or your store has a bank of Pi-powered monitors playing ads and the power is set to shut off every evening. Without the ability to shut down your Pi via the menu, you risk the SD card’s contents every time you power down your project.


Just in time of the plethora of Halloween projects we’re looking forward to this month, the clever folk at Adafruit have designed a solution for this issue. They’ve shared a script which forces the Raspberry Pi to run in read-only mode, so that powering it down via a plug pull will not corrupt the SD card.

But how?

The script makes the Pi save temporary files to the RAM instead of the SD card. Of course, this means that no files or new software can be written to the card. However, if that’s not necessary for your Pi project, you might be happy to make the trade-off. Note that you can only use Adafruit’s script on Raspbian Lite.

Find more about the read-only Raspberry Pi solution, including the script and optional GPIO-halt utility, on the Adafruit Learn page. And be aware that making your Pi read-only is irreversible, so be sure to back up the contents of your SD card before you implement the script.


It’s October, and we’re now allowed to get excited about Halloween and all of the wonderful projects you plan on making for the big night.

Adafruit read-only raspberry pi

Adafruit’s animated snake eyes

We’ll be covering some of our favourite spooky build on social media throughout the month — make sure to share yours with us, either in the comments below or on Facebook, Twitter, Instagram, or G+.


pi_user avatar

Very very awesome feature ! Many thanks !
I waited a such feature for a while, since I unsuccessfully tried some tutorials to achieve this.
Simmon, can we expect a such option integrated in a future release of Raspbian (in raspi-config menu) ?

horace avatar

yes, this absolutely should be an option in raspi-config!

so many raspberry pi projects need this and the solutions in the forum (which also work with the full raspbian and can be toggled on/off by the way) often stop working because something in the distro changed.

Wesley avatar

I have successfully used this tutorial to configure a Pi to be Read-Only:

It boots up Read-only by default, but has a simple “rw” command to remount it Read/Write, and “ro” to make it Read-only again.

I also set up the hardware watchdog to reboot the system if it stops responding:

This is running in a shop environment and plays a bell sound over the paging system to indicate start/end of work day, lunch, break, etc. It has been up and running about 6 months now with no problems yet.

Kevin avatar

huh? “making your Pi read-only is irreversible” … so you can’t pull the SD card set it up with the normal raspbian & use the card for read & write? That doesn’t seem right :(

Janina Ander avatar

To clarify, of course you can wipe the SD card and set it up all over again. However, that’s the only way to make your Pi read & write again after you’ve implemented the Adafruit script.

horace avatar

there are better scripts on the forum which also work with full raspbian and can easily be toggled on/off.

but it’s very good that this topic gets some attention because this should be something that is included in raspi-config since it’s important for so many raspberry pi projects.

Jeff Jackowski avatar

You mean that remounting the filesystem as read-write won’t work after the Adafruit script runs? Something like running this as root:

mount -o remount,rw /

Certainly it should be possible to modify /etc/fstab by mounting the root filesystem on another Linux installation to make it boot read/write again, but Adafruit’s script makes a number of other modifications, too.

SeljD avatar

did anyone test this on berryboot?

Gabriel Magana avatar

Great feature! Now the obligatory comment: I have an application where 99.999% of the info is read-only. I only need to store a tiny (but extremely critical) amount of state data, and still I need to be able to pull the plug to turn off. Any ideas on how to safely manage that?

I think for mass-produced headless devices shutting down via any sort of menu option is a nonstarter. People are going to pull the plug in order to shut down no matter what.

horace avatar

there are solutions on the forum where /boot stays writable. for small amounts of data this would be enough.

AndrewS avatar

It’d be safer to use a separate (small) partition for the writable data, so that even in the worst-case scenario of the entire partition being corrupted, the Pi would still remain bootable. For added robustness, you could even have an init script which reformats the writable partition if it’s been accidentally corrupted.

Bri avatar

maybe store your state-data in some non-volatile FRAM memory e.g this Adafruit product which can store 32kB and is accessible via I2C

Tom avatar

” be aware that making your Pi read-only is irreversible ”
Incorrect. It’s even stated in the article you can use a GPIO pin to reverse.

solar3000 avatar

readonly os has been requested lots of times.

this looks good.
cant wait to try it.

Barnabear avatar

I used the technique in the link below recently. It is effective and reversible. I don’t understand why this method is better?

esben avatar

Did you use this approach on the Stretch/ latest Raspbian?
I cannot for the life of me get it working correctly on a pi3 with stretch lite.

WarHawk (Brian C) avatar

What about a 10 min “sync”
reduce the writes to the drive by storing any small changes to compressed ZRAM, but write the logs/data with a rysnc?
10 min interval (configurable of course) would reduce the risk of losing the entire card…so if power loss would only lose that interval of updated data.

Dammsaint avatar

I wish this can be done not just on stretch lite.

tzj avatar

For a future release, i think both ideas should be implemented, reversable and permanent read only modes.

Milliways avatar

I wonder if any of the people who commented about reversibility actually studied the script. It does most of the obvious things (plus a few I hadn’t thought of) and looks OK for its intended use, but it UNINSTALLS a number of packages.
It wouldn’t be hard to write a script to reinstall, but then it isn’t that hard to shutdown properly, and not much harder to build a simple hardware solution which does an orderly shutdown if power is removed (obviously needs a short term storage system).

Jeromy avatar

On the topic of this adding the script makes it irreversible,
With a slight modification to the script perhaps this could be tog-able (RO/RW) with a couple of header pins.

Jeromy avatar

Perhaps I should have read more of the comments and more about the intimate workings of the script before making my last comment. -“just like me to jump in head first”

K R Leer avatar

This is very useful. I have just had a weather-station server been down with a scrambled file system after a power outage, and I’ve also had problems with other systems that I’d like to just keep running all the time. Prior to this, I did most of what this script does manually, so this turned out to be very convenient.

The script here worked great for me, starting with a fresh install of the most recent Raspbian Lite. Although it is irreversible in the sense that I can’t easily get things like cron and other things back, the system does allow me to re-mount the file systems read-write for when I want to make smaller changes, so I don’t have to pull the SD card and edit it on another machine.

knightswhosayNI avatar

Is it possible to use this image in a battery powered GPS logger?
The idea would be to run a logging script on the pi, run power from a powerbank and write to an external usb. Or does this just transfer the corruption problem to the USB drive?

Bill avatar

Read only from the SD chip seems like an excellent idea for the reasons given. However, there should be another option where writes can be made to a USB storage device. Weather stations, cameras, security sensors… should protect the OS on the SD from power failures but the logs on USB devices could withstand an abrupt end or programmed to add to the existing file to not lose any data.

Simon Long avatar

I’ve not looked into it, but I would have thought that it’s pretty easy for the user to make an external drive writeable even if the system drive is read-only; in fact, it may well be the case that external drives are writeable by default in this system.

Tomas avatar

Openvpn client service stopped working after going read only, it first was unable to resolve the vpn server address so I’ve added
to systemd openvpn client unit, it was able to resolve the name then, but stil no connection

Jaco avatar

If I use this scripts I loose NTP time. Why is that. I need to have the correct time and date as well. How can we put time back ?

Chris Schnick avatar

So, I configured a video looper following the directions on the Adafruit Raspberry Pi Video Looper

I installed this on a Raspian Stretch Lite version.

One I install this Read Only script, the video looper fails to alunch. Diffinf a little deeper, I see that the video looper uses the Supervisor service to autostart and that apparently the Supervisor service is killed by the Read Only process.

Any thoughts or ideas how I can get these two to play nicely?

I have images of my solution immediately prior to the running of the read only process if anyone wants to give it a go.


Comments are closed