Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

A file system that went read-only

By updated

Improve this page

Every write fails: the file system has gone read-only. Applications can no longer write their logs, the database refuses transactions, and sometimes the server stays reachable over SSH, which makes the diagnosis all the more confusing. The question to settle first is not "how do I remount read-write", but was it wanted or suffered. The two situations have neither the same cause nor the same repair, and the error message tells them apart.

What you will learn

  • Tell a deliberate read-only mount from an unwanted remount-ro after a disk error, thanks to the exact message
  • Read ext4 errors in the kernel log, the only reliable source
  • Understand why findmnt and tune2fs can lie to you
  • Repair with fsck and prove that writing is back

The error message names the cause

Two write failures, two distinct messages. This distinction is the heart of the diagnosis, and many administrators miss it:

Terminal window
touch /mnt/data/essai
Message receivedCodeWhat it means
Read-only file systemEROFSThe mount is read-only on purpose: ro option in /etc/fstab or at mount time
Input/output errorEIOThe device has failed. The file system protected itself

"Read-only file system" is a decision. "Input/output error" is an accident. The first is fixed by changing a mount option. The second signals a hardware or device error, and remounting read-write without doing anything else would only hide a problem that will come back, with data corruption at stake.

Case 1: read-only is intended

It is the simple case. The mount carries the ro option, and owns it:

Terminal window
touch /mnt/data/interdit
findmnt -o TARGET,OPTIONS /mnt/data
touch: cannot touch '/mnt/data/interdit': Read-only file system
/mnt/data ro,relatime

The message says Read-only file system, and findmnt confirms it by showing ro. Everything is consistent. Look for the ro option in /etc/fstab, fix it, then remount:

Terminal window
mount -o remount,rw /mnt/data
findmnt -o TARGET,OPTIONS /mnt/data

If the mount refuses to go back to read-write while fstab is correct, you are not in this case: move on to the next one.

Case 2: read-only is suffered, and your tools lie to you

Here, nobody asked for read-only. The kernel imposed it because the device returned errors, as set by the errors=remount-ro option.

Check the effective setting, in two places. The mount option, when it comes from /etc/fstab, takes precedence and shows up in findmnt -o OPTIONS (errors=remount-ro). The behaviour recorded in the superblock is read with tune2fs:

Terminal window
tune2fs -l /dev/sdb1 | grep -i 'errors behavior'
Errors behavior: Remount read-only

This setting is a protection, not a failure. Faced with a write error, the file system can choose between carrying on (and corrupting data), panicking (and stopping the machine), or freezing read-only. The third option preserves what can be preserved and leaves you in control. It is the one the installer sets on the root of a Debian or Ubuntu system, and the one to set yourself on your data volumes.

The trap: nothing you look at shows the failure

Here is the real state of a server whose disk has just failed. The outputs on this page come from a lab where the failure is simulated by a device-mapper device of type flakey, which starts refusing writes on demand: it shows up as /dev/mapper/disque_flakey. On a real server, it is the device named in the commands, here /dev/sdb1.

Terminal window
touch /mnt/data/nouveau
findmnt -o TARGET,SOURCE,FSTYPE,OPTIONS /mnt/data
tune2fs -l /dev/sdb1 | grep -i 'filesystem state'
touch: cannot touch '/mnt/data/nouveau': Input/output error
TARGET SOURCE FSTYPE OPTIONS
/mnt/data /dev/mapper/disque_flakey ext4 rw,relatime
Filesystem state: clean

Read these three outputs carefully. Writes fail. And yet:

  • findmnt shows rw. The mount still claims to be read-write. The options shown in /proc/mounts were not updated by the kernel's internal switch to read-only.
  • tune2fs shows clean. The file system state is read from the disk, but the kernel could not write the superblock to mark it in error, precisely because the disk no longer answers. The tool therefore reports a stale state.

The only source that tells the truth: the kernel log

Terminal window
journalctl -k | tail -20
# or, outside systemd:
dmesg | grep -iE 'EXT4-fs|I/O error'
EXT4-fs error (device dm-1): ext4_journal_check_start:84: Detected aborted journal
EXT4-fs (dm-1): I/O error while writing superblock
EXT4-fs (dm-1): Remounting filesystem read-only

Three lines, the whole diagnosis. The kernel hit a write error, it could not even update the superblock, it aborted the journal and remounted the file system read-only. The term aborted journal also explains why you get Input/output error and not Read-only file system: as long as the journal is aborted, every operation fails with EIO, even those that should simply be refused.

Also look for Buffer I/O error on dev lines, which point to the faulty device, and work back up the chain: if it is a physical disk, smartctl -H /dev/sdX will give its health status.

The disk comes back, the failure stays

A counter-intuitive point, with heavy consequences. Even when the device works perfectly again, the file system does not come back on its own to read-write:

Terminal window
dd if=/dev/mapper/disque_flakey of=/dev/null bs=4k count=1
touch /mnt/data/apres_hoquet
4096 bytes (4.1 kB, 4.0 KiB) copied, 1.1602e-05 s, 353 MB/s
touch: cannot touch '/mnt/data/apres_hoquet': Input/output error

The disk reads at 353 MB/s: it is perfectly fine. Writing still fails. A mount -o remount,rw is not enough in this state, because the journal stays aborted. You must unmount and repair.

Repair

The repair follows three steps, in this order. Deal first with the hardware cause if there is one: repairing a file system on a dying disk only postpones the inevitable.

1. Unmount

You never repair a mounted file system. If unmounting is refused because processes hold open files, identify them with lsof +f -- /mnt/data, stop them, and only use umount -l (lazy unmount) as a last resort.

Terminal window
umount /mnt/data

If the file system concerned is the root, unmounting is impossible: you must reboot into a rescue system, or force a check at the next boot. See Shut down, reboot, recover.

2. Check and repair with fsck

Terminal window
fsck.ext4 -fy /dev/sdb1 ; echo "exit=$?"
e2fsck 1.47.2 (1-Jan-2025)
/dev/mapper/disque_flakey: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 5: Checking group summary information
Free inodes count wrong (32756, counted=32755).
Fix? yes
***** FILE SYSTEM WAS MODIFIED *****
exit=1

-f forces the check even if the file system believes it is clean (remember that it calls itself clean), and -y answers yes to every question. On XFS, the default file system of RHEL, fsck checks nothing: it prints a pointer to xfs_repair(8) and exits with 0 (measured on Debian 13 and AlmaLinux 10). Repairing an unmounted XFS goes through xfs_repair, and a script that tests the $? of fsck wrongly concludes that the volume is healthy.

If you wish to check the consistency of an XFS filesystem or
repair a damaged filesystem, see xfs_repair(8).

3. Remount and prove that writing is back

Terminal window
mount /dev/sdb1 /mnt/data
findmnt -o TARGET,SOURCE,FSTYPE,OPTIONS /mnt/data
echo "reparation" > /mnt/data/verif.txt && echo "ecriture de nouveau possible"
/mnt/data /dev/mapper/disque_flakey ext4 rw,relatime
ecriture de nouveau possible

Seeing no error is not enough: actually write a file. It is the only proof that the service running on this mount will be able to work.

Troubleshooting

The table starts from what you observe, from the error message to a tool's misleading output, and gives the check that settles it. Remember the middle column: in the middle of a failure, only the kernel log can be trusted.

SymptomLikely causeVerificationFix
Read-only file systemDeliberate ro mountfindmnt -o OPTIONS shows roFix /etc/fstab, mount -o remount,rw
Input/output errorDisk error, aborted journaljournalctl -k | grep EXT4-fsUnmount, fsck -fy, remount
findmnt says rw but nothing gets writtenInternal remount-ro after an errorThe kernel log, never findmntfsck after unmounting
tune2fs says clean while everything breaksSuperblock not written (silent disk)journalctl -kDo not trust tune2fs in the middle of a failure
remount,rw changes nothingAborted journaljournalctl -k: aborted journalUnmount and fsck, a remount is not enough
umount refused (target is busy)Processes holding open fileslsof +f -- /mnt/dataStop the processes, umount -l as a last resort
The root / is read-onlySystem disk in errorConsole, journalctl -kReboot into rescue mode

Prevention

A triggered errors=remount-ro is a symptom, not the disease. Two reflexes prevent a recurrence. Monitor disk health with smartctl and monitoring that reports I/O errors: the disk has almost always given signs before failing. And monitor the kernel log: Buffer I/O error lines often appear days before the outright failure, without any application complaining yet.

Put it into practice

Faced with a stuck mount, theory evaporates fast: you need to have run through the sequence once already. The lab confronts you with a broken fstab that has left a mount read-only: it is up to you to read the kernel log, fix the faulty line and prove that writing is back with a real file.

Key points

  • The error message names the cause: Read-only file system (EROFS) is a wanted ro mount, Input/output error (EIO) is a suffered failure.
  • errors=remount-ro is not the default of a mkfs.ext4: a new volume comes out with Errors behavior: Continue, to be fixed with tune2fs -e remount-ro.
  • fsck on an XFS checks nothing and exits with 0: it points to xfs_repair(8). A script that tests $? wrongly concludes that the system is healthy.
  • errors=remount-ro is a protection, not a bug: ext4 freezes to avoid corrupting your data.
  • findmnt can show rw while the file system is blocked. Mount options are not updated by the internal switch to read-only.
  • tune2fs can show clean during the failure: it reads the superblock from a disk that no longer answers.
  • The kernel log is the only reliable source: journalctl -k or dmesg, and look for EXT4-fs error, aborted journal, Buffer I/O error.
  • A disk that works again does not repair the mount. You must unmount, fsck, remount.
  • fsck returning 1 has corrected errors: it is a success, not a failure.
  • Prove the repair by writing a file, do not settle for the absence of an error message.

Knowledge check

Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer