What the Error Means
Any program that tries to write gets Read-only file system: a package update, a log write, or a plain touch. There are three usual causes:
- The kernel remounted it after an error: ext4 with the option
errors=remount-ro, common on the root line of Debian and Ubuntu, switches to read-only when it finds corruption. - It was mounted read-only: an
rooption in/etc/fstab, or a manual mount. - The disk is failing: input/output errors can lead to the same remount.
Step 1: Read the Kernel Log
sudo dmesg -T | grep -iE 'error|read-only|ext4|xfs|i/o'
sudo journalctl -k -b
Look for lines from EXT4-fs that report an error and then a remount read-only, for I/O errors on a device such as vda, or for an XFS message that the file system was shut down. XFS does not remount; after a shutdown, access fails with input/output errors instead. Reading kernel messages is covered in the dmesg command.
Step 2: Check the Mount Options
findmnt -o TARGET,SOURCE,FSTYPE,OPTIONS /
grep -v '^#' /etc/fstab
An ro at the start of the options confirms the state. If fstab says ro for that file system and the kernel log is clean, the mount option is the cause: change it to defaults, test as in /etc/fstab explained, and remount.
Step 3: Save What You Can Read
When the kernel reported errors, copy your important data off the server before anything else, while it can still be read. A reboot of a damaged file system may not come back.
- Files: copy them to another machine with rsync or scp.
- Databases: a dump tool can usually still read; write the dump to another server, not to the read-only disk.
- Snapshot: if your provider's control panel offers one, take it now.
Step 4: Repair from Rescue Mode
A repair must never run on a mounted file system, and the root file system is always mounted on a running server. Boot the rescue system from the control panel, identify the disk, and check it:
lsblk -f
e2fsck -f -n /dev/vda1
e2fsck -f /dev/vda1
The first run only reports; the second asks before each fix. Do not start with -y. For XFS, use xfs_repair -n and then xfs_repair. Device names in rescue mode can differ from the installed system, so trust lsblk -f. The full procedure, with exit codes, is in how to check and repair a file system with fsck. Then boot normally.
Why remount,rw Is Not the Fix
sudo mount -o remount,rw /
This tells you something: if it fails, or the file system drops back to read-only within minutes, the kernel still sees errors. Even when it succeeds, writing to a file system with known damage can spread the damage. Use it as a diagnosis step, or in emergency mode to edit one file, not as the repair.
When the Disk Itself Is Failing
Repeated I/O errors for the same device mean hardware, not the file system. On a dedicated server, check the drive with smartctl and plan its replacement; with software RAID, replace the member as in software RAID with mdadm. On a cloud server, open a ticket with your hosting provider and include the kernel messages. In both cases, restore to healthy storage from your backup.
Other Read-Only Cases
- ISO images and some loop mounts: read-only by nature.
- Containers: a container started with a read-only root file system refuses writes outside its volumes.
- Network shares: the export on the other server may be read-only.