Read-only file system
This error occurs when you attempt to write, modify, or delete files on a partition mounted with read-only permissions.
Usually happens because:
- ☑ Kernel remounted partition due to bad blocks/errors
- ☑ Partition is explicitly mounted read-only inside /etc/fstab
- ☑ Docker volumes mounted with ro parameters (:ro)
🔍 Quick Checklist:
What is Read-only file system?
The 'Read-only file system' error is a standard POSIX system error associated with the error code EROFS. It indicates that the operating system blocked a write operation because the target block storage partition is mounted with read-only flags (ro). The kernel automatically remounts filesystems as read-only if it detects hardware errors, filesystem corruption, or bad blocks during active runtime checks, to prevent permanent data loss.
Common Causes
- Kernel auto-remount on disk errors: The kernel detected filesystem corruption or bad blocks, automatically changing the mount state to read-only.
- Explicit mount option settings: The device was mounted using the 'ro' flag inside system tables (e.g. /etc/fstab).
- Docker volume container safety: Attaching host directories to container volumes using the read-only flag suffix (:ro).
| Cause | Frequency |
|---|---|
| Kernel safety remount due to disk corruption | ⭐⭐⭐⭐⭐ |
| Docker volume mapped with read-only flag (:ro) | ⭐⭐⭐⭐ |
| System mount tables configuration (/etc/fstab) error | ⭐⭐ |
Common Mistakes
- Running `fsck` on an active, mounted partition. Doing so risks causing catastrophic file systems corruption.
- Ignoring disk error warnings in syslog logs, which typically precede kernel safety remounts.
How to Fix
Linux Operations & Verification
Force the kernel to update a partition's mount mode to read-write.
# 1. Inspect active mount options
$ mount | grep "/data"
/dev/sdb1 on /data type ext4 (ro,relatime)
# 2. Remount with write access flags
$ sudo mount -o remount,rw /data
# 3. Confirm modifications
$ mount | grep "/data"
/dev/sdb1 on /data type ext4 (rw,relatime)Platform Specific Fixes
List all read-only mounted filesystems on the server.
mount | grep -E ' (ro,'Best Practices
- Configure monitoring tools to scan `/var/log/syslog` or `dmesg` logs for disk device write faults.
- Ensure virtual machine disks reside on stable host SSD partitions.
Frequently Asked Questions (FAQ)
Q: What is EROFS?
EROFS is the POSIX system error code representing 'Read-only file system'.
Q: Why did my server disk suddenly become read-only?
If the Linux kernel detects disk errors (like bad sectors or metadata corruption), it immediately remounts the filesystem as read-only to protect your data from further damage.
Q: How do I fix a corrupted filesystem?
First unmount the partition ('sudo umount /dev/sdX1') and then run 'sudo fsck -y /dev/sdX1' to repair bad blocks. Never run fsck on a mounted filesystem.
Q: How do I remount a partition as read-write?
Run 'sudo mount -o remount,rw /' (replacing / with your target partition mount path).