Skip to content

Fix Read-Only File System on Raspberry Pi

If Raspberry Pi OS reports Read-only file system, inspect the directory where the write failed. The root filesystem, the boot partition and a USB drive can each have different mount settings. The mount and kernel logs help you decide whether to adjust a setting or preserve data first.

Find the mount that rejected the write

Replace /var/log with the existing directory where the program was trying to write. For a file that could not be created, use its parent directory.

1
2
3
4
# Show the mount that contains the failing path and compare it with root.
path=/var/log
findmnt -T "$path" -o TARGET,SOURCE,FSTYPE,VFS-OPTIONS,FS-OPTIONS
findmnt -T / -o TARGET,SOURCE,FSTYPE,VFS-OPTIONS,FS-OPTIONS

TARGET is the mount point. VFS-OPTIONS applies to that mount and FS-OPTIONS applies to the underlying filesystem. Look for ro or rw as a separate, comma-delimited option. The longer errors=remount-ro option describes what to do on a filesystem error. A mount can show that option while it is still writable. findmnt manual · ext4 mount options

VFS-OPTIONS FS-OPTIONS What it tells you
ro rw This mount is read-only. Another mount of the same filesystem may still allow writes.
ro ro Both this mount and the filesystem are read-only. Check the expected configuration and kernel logs.
rw rw The path you checked is writable at the mount level. Check the exact path and the failing program's view of it.

On a Pi 4B running Trixie, writes failed with Read-only file system both through a read-only bind mount of a writable temporary filesystem and through a separate read-only temporary filesystem. findmnt showed ro / rw for the bind and ro / ro for the second filesystem. On the same Pi, the regular boot partition showed rw in both columns and included errors=remount-ro in its filesystem options. Linux mount options

Choose the next step from the evidence

Configured boot protection or OverlayFS. Check /boot/firmware separately on Bookworm and Trixie with findmnt -T /boot/firmware. For a root mount with FSTYPE=overlay, an application can write successfully while its changes go to a temporary upper layer. If writes work and changes disappear after reboot, check the overlay and save needed data before changing modes. OverlayFS changes and boot partition protection

Only a service or container fails. Its view of the filesystem can differ from your SSH shell. Check the service's systemd settings such as ProtectSystem= and ReadOnlyPaths=, or the container's read-only bind mount options. Give the application a writable data directory if it needs to keep state. systemd filesystem access settings

A normally writable mount changed to read-only. Check the current boot's kernel logs and identify the device from the mount and block-device listings.

1
2
3
# Review recent kernel messages and match the device to its mount point.
sudo journalctl -k -b --no-pager -n 100
lsblk -o NAME,TYPE,RO,FSTYPE,MOUNTPOINTS

The RO column in lsblk is the block device's read-only flag. Use findmnt for the mount's settings and the journal to check why they may have changed.

If the logs show I/O errors, device resets or filesystem errors for that device, stop unnecessary writes and prioritize copying or imaging important data to separate storage. For repair, shut down and inspect the media from another system with the affected partition unmounted. Use a tool that matches the filesystem. For ext4, run e2fsck only with the partition unmounted and after preserving the data. Storage checks and recovery · e2fsck manual

Donate