How to Fix "Read-Only File System" Error in Linux
The "Read-only file system" error means Linux has mounted your filesystem as read-only, preventing any write operations. This usually happens after a system crash, improper shutdown, or filesystem corruption. Here is how to fix it.
Fix 1: Remount the Filesystem as Read-Write
The quickest fix is to remount the filesystem with read-write access. Run sudo mount -o remount,rw / for the root filesystem, or sudo mount -o remount,rw /mountpoint for other partitions. This often works if the filesystem was accidentally mounted read-only due to a minor error.
Fix 2: Check and Repair Filesystem
If remounting does not work, the filesystem may be corrupted. Unmount the partition with sudo umount /dev/sdXY, then run fsck to check and repair: sudo fsck -f /dev/sdXY. Do not run fsck on a mounted filesystem. For the root partition, you need to boot from a live USB to run fsck.
Fix 3: Force Filesystem Check on Next Boot
If you cannot unmount the root partition, force a filesystem check on the next reboot. Run sudo touch /forcefsck and then reboot. On the next boot, the system will run fsck automatically before mounting the filesystem. After the check completes and errors are fixed, the system should mount as read-write.
Fix 4: Check Disk Health
A failing hard drive can cause the system to remount as read-only to prevent data loss. Check disk health with sudo smartctl -a /dev/sda (install smartmontools first). Look for Reallocated_Sector_Ct, Current_Pending_Sector, and Offline_Uncorrectable values. If these are high, back up your data immediately and replace the drive.