How to Fix ‘Read-Only File System’ Error in Linux

Administering a Linux server, cloud VPS, or local workstation requires constant file modifications—such as creating configuration files, writing database transactions, or updating system packages. However, attempting a routine write command only to be blocked by the error: “Read-only file system” halts all system operations immediately. In Linux filesystems (such as ext4, XFS, and Btrfs), the operating system kernel enforces automated emergency protection policies. When the kernel detects physical disk I/O errors, storage controller drops, or severe filesystem metadata inconsistencies, it immediately remounts the affected partition as read-only (ro) to prevent further data corruption. While this protects stored records, resolving the underlying fault is required to return the drive to normal read-write operation. This technical guide outlines why Linux remounts filesystems as read-only and provides practical methods to repair and remount your drives.

Why Does Linux Switch Filesystems to Read-Only?

The Linux virtual filesystem (VFS) and block layer monitor storage health constantly. Common triggers for emergency read-only remounts include:

  • Filesystem Metadata Inconsistencies: Unclean system shutdowns, power loss, or kernel panics leaving orphan inodes and broken block bitmap allocators. By default, ext4 partitions configured with errors=remount-ro in /etc/fstab lock immediately upon detecting inconsistency.
  • Underlying Hardware Storage Degradation: Failing SSD NAND flash memory cells or hard drive bad sectors causing write timeouts at the SATA or NVMe controller level.
  • RAID or Cloud Storage Controller Detachment: In cloud environments (such as AWS EBS, DigitalOcean Droplets, or Hetzner Cloud), momentary hypervisor storage bus interruptions causing the guest kernel to lose the block device.
  • Incorrect Mount Options in /etc/fstab: The filesystem explicitly declared with the ro mount parameter inside the filesystem table.
  • Read-Only Physical Hardware Lock: MicroSD cards or USB flash drives with a physical write-protect lock slider engaged.

Method 1: Check Kernel Diagnostic Logs with dmesg

The Linux kernel ring buffer records the exact hardware or filesystem fault that triggered the read-only switch.

  1. Open your Linux terminal.
  2. Examine recent kernel error messages:
    sudo dmesg | grep -iE 'error|read-only|ext4|xfs|btrfs|ata|nvme'
  3. Look for lines stating:
    “EXT4-fs error (device sda1): remounting filesystem read-only” or “I/O error, dev nvme0n1, sector…”
  4. This diagnostic string confirms the exact device identifier (e.g. /dev/sda1 or /dev/nvme0n1p2) that encountered the fault.

Method 2: Attempt Immediate Read-Write Remount

If the error was triggered by a momentary transient cloud storage blip and metadata is uncorrupted, remounting read-write restores service immediately.

  1. Execute the remount command targeting your affected partition (e.g. the root partition /):
    sudo mount -o remount,rw /
  2. Test writing a temporary file:
    touch /tmp/test_write.txt && rm /tmp/test_write.txt
  3. If the write succeeds, the filesystem is restored to read-write mode.
  4. If the command fails with “mount: cannot remount … read-write, is write-protected”, serious filesystem metadata corruption is present and requires fsck.

Method 3: Run Filesystem Consistency Check (fsck) in Single-User / Rescue Mode

Important: Never run fsck on an actively mounted read-write filesystem. Perform repairs on unmounted partitions or during emergency boot.

  1. For secondary data drives (e.g. /dev/sdb1), unmount the volume first:
    sudo umount /dev/sdb1
  2. Run the filesystem repair utility:
    sudo fsck -y /dev/sdb1
  3. For the primary root partition (/), schedule a filesystem check on the next system reboot:
    sudo touch /forcefsck
    sudo reboot
  4. Alternatively, if dropped into an Emergency / Maintenance shell during boot, run:
    fsck -f /dev/sda1
  5. Press Y to approve repairs to corrupted inode pointers, extent trees, and directory entries.
  6. Reboot the system into normal multi-user mode once repairs conclude.

Method 4: Inspect /etc/fstab for Incorrect Mount Parameters

Verify that the filesystem configuration file does not permanently dictate read-only operation.

  1. Open the filesystem table configuration:
    sudo nano /etc/fstab
  2. Locate your partition entry.
  3. Review the options column. Ensure it specifies defaults or rw, not ro.
  4. A standard ext4 root partition entry should resemble:
    UUID=xxxx-xxxx-xxxx  /  ext4  errors=remount-ro  0  1
  5. Save changes if modifications were made.

Method 5: Check Storage Drive S.M.A.R.T. Health Status

If filesystems drop to read-only repeatedly, physical storage media failure is imminent.

  1. Install the smartmontools utility:
    sudo apt install smartmontools -y
  2. Run an overall health check against your drive:
    sudo smartctl -H /dev/sda
  3. Inspect detailed attribute tables:
    sudo smartctl -A /dev/sda
  4. Look for high counts under Reallocated_Sector_Ct, Current_Pending_Sector, or Available Spare (for NVMe drives). If bad sectors are proliferating, immediately back up essential data and replace the drive.

For more Linux system administration guides and filesystem troubleshooting solutions, visit our Digitash Terminal section.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.