Linux: Read-only file system (EROFS) on a mounted volume
EROFS is a mount condition, not a permission error. Read the kernel log first: I/O errors, a full thin pool, an ro fstab entry or a read-only root.

Introduction & Quick Summary
touch: cannot touch '/var/log/app.log': Read-only file systemEROFS means the kernel refused a write because the filesystem is mounted read-only or has switched itself to read-only. It is a mount-level condition, not a permission problem: chmod, chown and sudo cannot change it, and the fix always starts with identifying which mount is affected and why it is read-only.
Four causes, in rough order of frequency on servers:
- A filesystem error forced a remount. ext4 with
errors=remount-ro, XFS after a log I/O error, and Btrfs after checksum failures all flip to read-only to protect data. - The storage behind it filled up. A full LVM thin pool or a full Btrfs device makes writes fail, and some stacks surface that as read-only.
- An explicit
rooption./etc/fstab, a bind mount, or a container runtime flag asked for read-only and nobody remembered. - A network filesystem. An NFS export marked
ro, or a server that went read-only, propagates to every client.
| Mount source | Read-only trigger | First check |
|---|---|---|
| ext4 | I/O error, errors=remount-ro | kernel log via dmesg -T |
| XFS | Log I/O error, shutdown | xfs_info, kernel log |
| Btrfs | Checksum or device error | btrfs device stats / |
| LVM thin | Pool data or metadata full | lvs -o data_percent,metadata_percent |
| NFS | Export ro or server policy | findmnt -no SOURCE,OPTIONS /mnt |
| overlayfs | --read-only or readOnlyRootFilesystem | findmnt / inside the container |
Core Mechanics, Signatures & Reproducible Setup
A mount carries flags in the kernel's mount table. MS_RDONLY makes every write path return EROFS before permissions are even considered. Filesystems can set that flag themselves through an error policy, and mount -o remount,rw clears it only if the underlying condition is gone — otherwise the filesystem remounts read-only again within seconds.
Identify the offending mount and its options:
findmnt -no TARGET,SOURCE,FSTYPE,OPTIONS /
mount | grep -E '\(ro[,)]'
cat /proc/mounts | awk '$4 ~ /^ro,/ {print $2, $4}'Then read the kernel's reason:
dmesg -T | grep -iE 'ext4|xfs|btrfs|i/o error|remount|read-only' | tail -30
journalctl -k --since "-1 hour" | tail -50A healthy read-only mount is silent in the kernel log. A forced remount is preceded by the actual failure, often an I/O error on a specific block or a metadata checksum mismatch:
EXT4-fs error (device nvme0n1p2): ext4_lookup:1831: inode #2: comm nginx: deleted inode referenced: 131075
EXT4-fs (nvme0n1p2): Remounting filesystem read-onlyReproduce the benign version safely with a loopback file so you can see the error text without touching production:
dd if=/dev/zero of=/tmp/ro.img bs=1M count=32
mkfs.ext4 -q /tmp/ro.img
mkdir -p /mnt/rotest
mount -o loop,ro /tmp/ro.img /mnt/rotest
touch /mnt/rotest/x
# touch: cannot touch '/mnt/rotest/x': Read-only file system
findmnt -no OPTIONS /mnt/rotest
# ro,relatime
umount /mnt/rotestThe same message, but here the mount option is the whole story and remounting rw is legitimate.
Key Comparison Table
| Filesystem | On error | Recovery command | Risk |
|---|---|---|---|
| ext4 | Remounts read-only | fsck.ext4 -f on unmounted device | Low if clean |
| XFS | Shuts down the log | xfs_repair after unmount | Data loss possible |
| Btrfs | Remounts read-only | btrfs scrub, replace device | Medium |
| NFS | Client sees EROFS | Fix export or server | None locally |
| overlayfs | EROFS at container root | Remove --read-only | None |
| tmpfs | Never remounts read-only | n/a | n/a |
| Command | Purpose | Safe on mounted fs |
|---|---|---|
findmnt -no OPTIONS / | Confirm ro flag | Yes |
mount -o remount,rw / | Try to restore writes | Yes, briefly |
df -h, df -i | Rule out space exhaustion | Yes |
lvs -o data_percent | Thin pool saturation | Yes |
fsck -n /dev/sdX | Read-only check | Yes |
fsck -f /dev/sdX | Repair | No, requires unmount |
xfs_repair -n | Dry run | Yes, unmounted |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
Case 1: ext4 remounted after an I/O error
mount -o remount,rw /
# mount: /: mount point not mounted or bad optionThat message usually means the remount failed because the filesystem already decided it is broken. The sequence that actually works starts with the cause:
dmesg -T | grep -i 'i/o error' | tail
smartctl -a /dev/nvme0n1 | grep -iE 'media|reallocated|error'If the device is failing, replacing it is the fix; remounting only postpones the next failure. If the error was transient (a cable, a flaky controller), schedule a filesystem check at the next boot:
tune2fs -c 1 /dev/nvme0n1p2
shutdown -r nowfsck must run on an unmounted filesystem. For the root filesystem that means a rescue environment or fsck.mode=force on the kernel command line.
Case 2: LVM thin pool full
lvs -o lv_name,data_percent,metadata_percent,pool_lv
# root 99.98 12.10 pool0When a thin pool reaches 100%, the kernel marks thin volumes read-only instead of corrupting them. Free space by deleting snapshots, then extend the pool:
lvs -o lv_name,lv_size,pool_lv
lvextend -L +20G /dev/vg0/pool0Extending the pool alone does not always restore the read-only flag; a remount may be required, and a filesystem check is advisable after any full-pool event.
Case 3: A container with a read-only root
docker run --rm alpine touch /test
# touch: /test: Read-only file systemCheck how the container was started before editing anything:
docker inspect <id> --format '{{ .HostConfig.ReadonlyRootfs }}'
docker inspect <id> --format '{{ json .Mounts }}'If ReadonlyRootfs is true, the design is intentional and the application must write to a mounted volume or tmpfs:
docker run --rm --read-only --tmpfs /tmp alpine sh -c 'echo ok > /tmp/x'In Kubernetes the equivalent is securityContext.readOnlyRootFilesystem: true, and the fix is an emptyDir mounted at the write path, not a privileged container.
Case 4: NFS export mounted read-only
findmnt -no SOURCE,OPTIONS /mnt/data
# 10.0.0.5:/export/data rw,relatime,vers=4.2,...If the client shows rw but writes fail with EROFS, the server exported the path read-only:
# on the server
exportfs -v
# /export/data 10.0.0.0/24(ro,sync,wdelay,...)Change the export to rw, re-export, and remount on the client:
exportfs -ra
mount -o remount /mnt/dataA stale file handle error is different: it means the export changed identity, and the client must unmount and remount rather than remount in place.
Case 5: ro sneaked into fstab
UUID=6f1a... /srv/data ext4 defaults,ro,nofail 0 2A ro in the options column applies at every boot. It is easy to introduce while troubleshooting and easy to forget:
findmnt --verify --verbose
grep -n ' ro' /etc/fstabFix the line, then apply without rebooting:
mount -o remount,rw /srv/data
systemctl daemon-reloadfindmnt --verify also catches duplicate mount points and unknown options, which otherwise surface as silent boot failures.
Case 6: Btrfs device errors and read-only subvolumes
btrfs device stats /
btrfs filesystem show /Non-zero read_errors or corruption_errors mean the device layer, not Btrfs configuration. A subvolume mounted ro (common with snapshot tooling) is a separate case:
btrfs property get /mnt/snapshot ro
btrfs property set /mnt/snapshot ro falseSnapshots created for backups should stay read-only; flipping one to writable decouples it from the snapshot semantics the backup tool relies on.
Common Compilation/Runtime Mistakes & Version Gotchas
chmodandsudocannot fixEROFS. They change metadata on a filesystem that refuses metadata writes. Confirm the mount flag first, or the next hour is wasted.- Remounting without reading the log.
mount -o remount,rwsucceeds for seconds and then the filesystem flips back, which looks like the command did nothing. The kernel log has the reason. errors=remount-rois a feature. Removing it from fstab to "stop the remounts" converts a protected read-only state into silent corruption. Fix the underlying I/O instead.fsckon a mounted filesystem. ext4 refuses, XFS may report spurious damage, and Btrfs can make things worse. Unmount first, or use a snapshot.- systemd mount units. A unit with
Options=rooverrides fstab changes untilsystemctl daemon-reloadruns; the mount looks correct in fstab and stays read-only in reality. - Immutable and overlay layers. In containers,
EROFScan come from the image layer rather than the mount table when/etcis a bind mount from the host. Inspectfindmntinside the namespace, not on the host.
To verify that a file was not partially written before the filesystem went read-only, compare its checksum against the expected value with the hash generator. Permission changes that look related but are not belong in the chmod calculator, which shows the octal and symbolic forms side by side.
Primary references: mount(2) lists EROFS among the mount errors and documents MS_RDONLY, and fstab(5) defines the options column that silently applies ro at boot.
Official references
primary documentationThe Linux documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Linux work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Linux guides
All Linux guidesnginx 502 Bad Gateway: upstream connection refused
The log line names the address and errno, which is the diagnosis. Fix the host, the start-up order, the buffers, or the timeout that actually fired.
Linux Networking Diagnostics: ss, ip, dig, curl, and TCP Troubleshooting
A layer-by-layer path from interface to TLS that localises a failure in five commands, with the socket states and curl timings that identify each cause.
apt: The repository does not have a Release file
apt disables any repository whose Release file returns 404. Correct the suite name, move an end-of-life release to the archive host, or remove a dead repo.
Linux: bind: Cannot assign requested address
EADDRNOTAVAIL means the kernel had no address to bind: too many TIME_WAIT sockets, an IP missing from the interface, or a wrong listen address.
More in Linux
All Linux guidesThe guides filed next to this one in Linux, in library order.