Linuxexit code > 0

Read-only file system

$touch: cannot touch 'file': Read-only file system

Analysis

The filesystem is mounted as read-only, preventing any modifications.

Common Triggers

  • Filesystem corruption detected (OS remounts as RO for safety).
  • Running inside a read-only container/volume.
  • Incorrect /etc/fstab options.

Debug Checks

  • $Check mount status: mount | grep " ro,".
  • $Check kernel logs: dmesg | grep -i error.

Resolution

1
Remount as RW: mount -o remount,rw /mountpoint (if healthy).
2
Run fsck to fix corruption (requires unmounting).