Raspberry Pi OverlayFS: Read-Only Root and Kiosk Guide¶
Raspberry Pi OS can protect its root filesystem with OverlayFS so runtime changes go to a temporary RAM-backed upper layer and disappear after reboot. This is useful for kiosks, classroom devices, digital signs, and appliances that must return to a known state. It is not appropriate until every required persistent file has a deliberate home.
Quick answer¶
- Update and back up the working system.
- List databases, logs, keys, uploads, and state that must persist.
- Move that data to a separate writable filesystem where necessary.
- Open
sudo raspi-config. - Choose Performance Options → Overlay File System.
- Enable the root overlay; decide separately whether to protect the boot partition.
- Reboot and prove that disposable changes vanish while required data remains.
- Document how to disable the overlay before future OS updates.
The official Raspberry Pi configuration documentation describes the supported menu and desktop controls. Raspberry Pi also publishes an application note on making a more resilient filesystem.
How OverlayFS works¶
| Layer | Purpose | Survives reboot in the Raspberry Pi OS read-only-root mode? |
|---|---|---|
| Lower | Original root filesystem | Yes, but remains unchanged while overlay is active |
| Upper | New and modified files | No; stored in RAM for the supported temporary overlay |
| Work | Internal OverlayFS operations | No |
| Merged | Combined view applications use as / |
Presents both layers |
When a program first changes a file from the lower layer, OverlayFS copies it to the upper layer and modifies that copy. Deleting a lower-layer file creates a whiteout in the upper layer. The lower file remains intact and becomes visible again after the temporary upper layer is discarded.
This differs from a Device Tree overlay. Both use the word “overlay,” but a Device Tree overlay describes hardware; OverlayFS combines filesystem layers.
Decide whether OverlayFS fits¶
Good candidates¶
- kiosk or digital-signage image restored by reboot
- supervised classroom or exhibition device
- disposable integration-test system
- appliance configured through a separate persistent data partition
- system exposed to unexpected power removal after its data path is designed accordingly
Poor candidates without redesign¶
- database or home server writing state throughout
/var/lib - system that receives unattended upgrades while overlay is active
- remote-only device with no tested recovery route
- desktop expected to retain accounts, browser profiles, and package changes
- recorder, camera, or sensor logger without separate persistent storage
OverlayFS reduces writes to the lower root while active. It does not replace clean shutdown, reliable power, backups, or suitable storage.
Inventory persistent data¶
Run the real workload for an hour, then inspect recently modified files:
Check common state directories:
Classify every write:
| Data | Usually persistent? | Example strategy |
|---|---|---|
| Application database | Yes | Separate writable filesystem and backup |
| SSH host keys | Yes | Preserve /etc/ssh state in the base image |
| VPN identity/state | Yes | Persistent application-specific directory |
| Uploads and recordings | Yes | Dedicated data filesystem |
| Package changes | Yes | Disable overlay during maintenance |
| Temporary cache | No | Leave in upper layer or bounded tmpfs |
| Debug logs | Depends | Remote logging or bounded persistent location |
Do not bind-mount broad directories such as all of /etc or /var without understanding what becomes writable and how it is backed up.
Prepare a rollback¶
Before activation:
Create a restorable image or file-level backup, and keep another bootable storage device. Record:
- Raspberry Pi model and OS release
- root and boot device names
- enabled services
- persistent mount definitions
- the exact procedure to disable OverlayFS
- how to attach a keyboard/display or mount
bootfselsewhere
Test the backup restoration before deployment. A backup that has never been restored is only an assumption.
Enable the supported read-only root¶
Open the configuration menu:
Choose Performance Options → Overlay File System. The tool asks two distinct questions:
- Enable the overlay for the root filesystem.
- Write-protect the boot partition.
Enable only the root overlay for the first test. Keeping the boot partition writable initially simplifies recovery; protect it later only if the threat model requires it and the maintenance process works.
Reboot when prompted:
Verify that it works¶
Inspect mounts after reconnecting:
Create a disposable marker:
After reboot, the marker should be absent:
Now verify the data that must persist. Create a marker in the dedicated writable location, restart the application, reboot, and confirm its database, uploads, identity, and configuration remain valid.
Measure RAM and upper-layer growth¶
The temporary upper layer consumes memory as files change. Monitor the system during the longest expected workload:
Also check memory pressure and OOM history:
If the upper layer grows without bound, identify the writer with iotop and application logs. Do not solve it by assigning all RAM to the overlay; fix or relocate the write source.
Use the memory pressure and OOM guide for a repeatable load test.
Maintenance and OS updates¶
Changes made while the root overlay is active disappear after reboot, including package installations and configuration edits. Use this maintenance sequence:
- Schedule downtime and confirm recent backups.
- Disable OverlayFS using the same
raspi-configmenu. - Reboot and verify that
/is writable without the temporary overlay. - Apply updates and required configuration.
- Reboot once and test the application with OverlayFS still disabled.
- Re-enable OverlayFS.
- Reboot again and run persistence and reset tests.
Example update checks while the overlay is disabled:
Do not automate updates during the overlay-enabled state and assume they were committed to the lower filesystem.
Disable OverlayFS¶
Open:
Return to Performance Options → Overlay File System, disable the root overlay, and remove boot write protection if maintenance requires it. Reboot and verify:
If the menu cannot complete, use the documented backup/recovery path rather than copying undocumented initramfs commands from another OS release.
Recover a system that does not boot¶
- Disconnect power and remove the storage only after activity stops.
- Mount
bootfson another computer or boot known-good recovery media. - Preserve a copy of the current boot files before editing.
- Inspect recent changes and free space.
- Restore the last working configuration or disable the overlay through the supported tool from a bootable environment.
- Boot with a display/console attached and inspect the journal.
Do not repeatedly power-cycle a filesystem that may be damaged. Image or back up important partitions before repair attempts.
Directory-level OverlayFS experiment¶
To learn the lower/upper/work/merged model without changing the root filesystem, use disposable directories:
upperdir and workdir must be on the same filesystem, and workdir must be empty. See the Linux kernel OverlayFS documentation for filesystem requirements and advanced behaviour.
Benchmark checklist¶
Compare the same workload with and without OverlayFS:
| Metric | Normal root | OverlayFS root |
|---|---|---|
| Test duration | ||
| Application-ready time | ||
| Root device writes | ||
| Peak RAM used | ||
| Peak memory PSI | ||
| Persistent-data test | ||
| Reboot-reset test | n/a | |
| Update/recovery test |
Record raw data and leave result cells blank until measured on named hardware. Use the benchmark methodology to control power, cooling, storage, and repetitions.
Common mistakes¶
- Confusing OverlayFS with Device Tree overlays
- Enabling it before classifying persistent data
- Protecting
/bootbefore testing the maintenance path - Assuming package updates persist while the overlay is active
- Storing databases or identity only in the temporary upper layer
- Ignoring RAM growth on a low-memory board
- Using manual initramfs scripts copied from a different OS release
- Treating read-only root as a backup
FAQ¶
Does Raspberry Pi OS include OverlayFS support?¶
Yes. Current Raspberry Pi OS exposes a supported read-only-root option in the desktop Control Centre and raspi-config.
Are changes saved while OverlayFS is enabled?¶
Changes to the overlaid root are temporary and disappear after reboot. Separately mounted writable data can persist.
Does OverlayFS prevent every SD card write?¶
No. The boot partition and other writable filesystems may still receive writes. Measure the actual block devices.
Can I update Raspberry Pi OS with OverlayFS enabled?¶
Commands may appear to work, but root changes are placed in the temporary layer. Disable the overlay, reboot, update and test, then re-enable it.
Is OverlayFS faster?¶
RAM-backed writes can be faster, but copy-up and memory pressure have costs. Its primary value here is controlled persistence and reduced lower-root writes, not a guaranteed speed increase.