Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

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.

~5 min readLinux
#Linux#Filesystems#Storage#Troubleshooting
A Linux disk volume locked behind a cyan read-only gate, an amber mount option plate and a kernel log card

Introduction & Quick Summary

text
touch: cannot touch '/var/log/app.log': Read-only file system

EROFS 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 ro option. /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 sourceRead-only triggerFirst check
ext4I/O error, errors=remount-rokernel log via dmesg -T
XFSLog I/O error, shutdownxfs_info, kernel log
BtrfsChecksum or device errorbtrfs device stats /
LVM thinPool data or metadata fulllvs -o data_percent,metadata_percent
NFSExport ro or server policyfindmnt -no SOURCE,OPTIONS /mnt
overlayfs--read-only or readOnlyRootFilesystemfindmnt / 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:

bash
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:

bash
dmesg -T | grep -iE 'ext4|xfs|btrfs|i/o error|remount|read-only' | tail -30 journalctl -k --since "-1 hour" | tail -50

A 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:

text
EXT4-fs error (device nvme0n1p2): ext4_lookup:1831: inode #2: comm nginx: deleted inode referenced: 131075 EXT4-fs (nvme0n1p2): Remounting filesystem read-only

Reproduce the benign version safely with a loopback file so you can see the error text without touching production:

bash
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/rotest

The same message, but here the mount option is the whole story and remounting rw is legitimate.

Key Comparison Table

FilesystemOn errorRecovery commandRisk
ext4Remounts read-onlyfsck.ext4 -f on unmounted deviceLow if clean
XFSShuts down the logxfs_repair after unmountData loss possible
BtrfsRemounts read-onlybtrfs scrub, replace deviceMedium
NFSClient sees EROFSFix export or serverNone locally
overlayfsEROFS at container rootRemove --read-onlyNone
tmpfsNever remounts read-onlyn/an/a
CommandPurposeSafe on mounted fs
findmnt -no OPTIONS /Confirm ro flagYes
mount -o remount,rw /Try to restore writesYes, briefly
df -h, df -iRule out space exhaustionYes
lvs -o data_percentThin pool saturationYes
fsck -n /dev/sdXRead-only checkYes
fsck -f /dev/sdXRepairNo, requires unmount
xfs_repair -nDry runYes, unmounted

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

Case 1: ext4 remounted after an I/O error

bash
mount -o remount,rw / # mount: /: mount point not mounted or bad option

That message usually means the remount failed because the filesystem already decided it is broken. The sequence that actually works starts with the cause:

bash
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:

bash
tune2fs -c 1 /dev/nvme0n1p2 shutdown -r now

fsck 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

bash
lvs -o lv_name,data_percent,metadata_percent,pool_lv # root 99.98 12.10 pool0

When 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:

bash
lvs -o lv_name,lv_size,pool_lv lvextend -L +20G /dev/vg0/pool0

Extending 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 system

Check how the container was started before editing anything:

bash
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

bash
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:

bash
# 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:

bash
exportfs -ra mount -o remount /mnt/data

A 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

fstab
UUID=6f1a... /srv/data ext4 defaults,ro,nofail 0 2

A ro in the options column applies at every boot. It is easy to introduce while troubleshooting and easy to forget:

bash
findmnt --verify --verbose grep -n ' ro' /etc/fstab

Fix the line, then apply without rebooting:

bash
mount -o remount,rw /srv/data systemctl daemon-reload

findmnt --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

bash
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:

bash
btrfs property get /mnt/snapshot ro btrfs property set /mnt/snapshot ro false

Snapshots 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

  • chmod and sudo cannot fix EROFS. 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,rw succeeds for seconds and then the filesystem flips back, which looks like the command did nothing. The kernel log has the reason.
  • errors=remount-ro is 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.
  • fsck on 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=ro overrides fstab changes until systemctl daemon-reload runs; the mount looks correct in fstab and stays read-only in reality.
  • Immutable and overlay layers. In containers, EROFS can come from the image layer rather than the mount table when /etc is a bind mount from the host. Inspect findmnt inside 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 documentation

The Linux documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Linux work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Linux guides

More in Linux

All Linux guides

The guides filed next to this one in Linux, in library order.