Troubleshoot "Read-only file system" errors on a Linux instance

Updated at:
Copy as MD

Problem description

After you restart a Linux ECS instance, the operating system runs normally, but Read-only file system *** errors appear when you run commands such as charrt, mkdir, and cat.

  • Running chattr on sshd_config returns the Read-only file system *** error.Read-only file system

  • Running mkidr to create a directory returns the cannot create directory 'test': Read-only file system *** error.

    mkdir

  • Running cat returns the cannot create temp file for here-document: Read-only file system *** error.

    cat

Causes

Possible causes:

  • The /etc/fstab file specifies the ro option for the root file system (/), preventing write operations.

  • No mount option is specified for / in /etc/fstab. After a restart, the system defaults to ro, preventing write operations.

Solution

Change the mount option for the root file system in /etc/fstab

  1. Connect to the Linux ECS instance with VNC. See Choose a connection method.

  2. Check the mount option for the root file system.

    cat /etc/fstab
    • If the output shows the ro option for the root file system (/), change it to rw. ro mode

    • If no mount option is specified for /, the system defaults to ro. Set the option to rw.

      image

  3. Remount the root file system read-write (rw).

    mount -o remount rw /
  4. Set the mount option for / to rw in /etc/fstab.

    1. Open /etc/fstab.

      vim /etc/fstab
    2. Set the mount option for / to rw.

      Change mount option to rw

    3. Press Esc, enter :wq, and press Enter to save.

    4. Restart the instance for the change to take effect.

      reboot