How to Fix ‘chmod: changing permissions of … Read-only file system’ in Linux

Attempting to modify file attributes or execute administrative permissions in Linux using chmod +x script.sh or chmod 755 /var/www only to be stopped by the error: ‘chmod: changing permissions of \’file\’: Read-only file system’ brings system administration to a halt. In Linux filesystem architecture, when an underlying storage device encounters severe I/O errors, storage controller timeouts, bad disk sectors, or filesystem metadata corruption, the Linux kernel automatically remounts the affected partition as read-only (ro) to prevent catastrophic data destruction.

Why Does Linux Remount Filesystems as Read-Only?

The read-only filesystem lock is an emergency self-preservation mechanism triggered by the kernel:

  • Filesystem Corruption Detected: The filesystem driver (ext4, XFS, Btrfs) detecting invalid inode pointers or broken block allocations, executing its configured errors=remount-ro policy.
  • Hardware Storage Controller Timeouts: Dropped SATA, NVMe, or USB bus connections causing the kernel to lose write acknowledgment.
  • Unclean Shutdowns or Power Outages: Abrupt power interruptions leaving filesystem journal transactions incomplete.
  • Failing Physical Drive or Bad Sectors: SMART disk degradation forcing read-only protection.
  • Explicit Read-Only Mount Flags in /etc/fstab: Storage mounts configured with ro instead of rw.

Step 1: Inspect Mounted Filesystem Status with mount

Identify which partition has been placed into read-only mode.

  1. Open your terminal and run:
    mount | grep -w 'ro'
  2. Inspect the output to pinpoint the mount point (e.g. /dev/sda1 on / type ext4 (ro,relatime)).
  3. Check the kernel ring buffer to view the exact error that triggered the lock:
    sudo dmesg -T | grep -E -i 'error|read-only|ext4|i/o' | tail -n 20

Step 2: Remount the Filesystem as Read-Write (rw)

If the error was caused by a transient bus timeout or configuration error, remounting restores immediate write access.

  1. Execute the remount command with root privileges:
    sudo mount -o remount,rw /
    (Replace / with your specific mount point, e.g. /data or /mnt/storage).
  2. Test creating or modifying a file:
    touch /tmp/test_write && rm /tmp/test_write
  3. If the remount fails with ‘Cannot remount read-write: Filesystem has errors’, proceed to filesystem check repairs.

Step 3: Check and Repair Filesystem Errors with fsck

Repairing corrupted filesystem journal structures allows the kernel to mount partitions in read-write mode safely.

  1. Important: Never run fsck on an actively mounted read-write filesystem. Ensure the target is unmounted or read-only.
  2. If repairing a secondary drive:
    sudo umount /dev/sdb1
    sudo fsck -yf /dev/sdb1
  3. If repairing the primary root partition (/), force a filesystem check on the next boot:
    sudo touch /forcefsck
    sudo reboot
  4. Alternatively, boot from an Ubuntu Live USB, open terminal, and run:
    sudo fsck -yf /dev/sdX1

Step 4: Inspect /etc/fstab for Incorrect Mount Options

Ensure permanent mount configuration entries do not specify read-only flags.

  1. Open /etc/fstab in a text editor:
    sudo nano /etc/fstab
  2. Review the mount options for your drives. Ensure options specify defaults or rw rather than ro.
  3. Save changes if modifications were made.

Step 5: Check Physical Drive SMART Health

Verify whether hardware drive degradation is triggering safety locks.

  1. Install smartmontools:
    sudo apt install smartmontools -y
  2. Run a drive health check:
    sudo smartctl -H /dev/sda
  3. If the output reports FAILED or high reallocated sector counts, back up all critical files immediately and replace the physical drive.

Inspecting kernel messages with dmesg, remounting partitions via mount -o remount,rw, running fsck disk repairs, and checking SMART health resolves ‘chmod: Read-only file system’ in Linux.

Get the best tech tips delivered straight to your inbox.

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