All Products
Search
Document Center

:What do I do if "Read-only file system ***" error messages appear when I modify files on a Linux instance?

Last Updated:Jul 02, 2024

Problem description

After you restart a Linux Elastic Compute Service (ECS) instance, the instance operating system runs as expected, but Read-only file system *** error messages appear when you run the charrt, mkdir, and cat commands on the instance.

  • When you run the chattr command to modify the sshd_config file, the Read-only file system *** error message appears.Read-only file system

  • When you run the mkidr command to create a directory, the cannot create directory 'test': Read-only file system *** error message appears.

    mkdir

  • When you run the cat command to view the content of a file, the cannot create temp file for here-document: Read-only file system *** error message appears.

    cat

Causes

The issue may occur due to the following reasons:

  • The default mount option ro is configured in the /etc/fstab configuration file of the Linux ECS instance to mount the root file system (/) read-only. As a result, the system or processes cannot write files to the root file system, and the Linux ECS instance cannot start or system services cannot run as expected.

  • No mount option is configured in the /etc/fstab configuration file of the Linux ECS instance to mount the root file system (/). After you restart the Linux ECS instance, the default mount option (ro) is used to mount the root file system (/) read-only. As a result, the system or processes cannot write files to the root file system, and the Linux ECS instance cannot start or system services cannot run as expected.

Solution

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

  1. Connect to the Linux ECS instance by using Virtual Network Computing (VNC).

    For more information, see Connection method overview.

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

    cat /etc/fstab
    • The following command output indicates that the ro mount option is used to mount the root file system (/) read-only. Set the mount option to rw to mount the root file system read-write. ro模式

    • The following command output indicates that no mount option is configured for the root file system (/) and the default mount option (ro) is used to mount the root file system. Set the mount option to rw to mount the root file system read-write.

      image

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

    mount -o remount rw /
  4. Set the mount option for the root file system (/) in the /etc/fstab configuration file to rw.

    1. Open the /etc/fstab configuration file.

      vim /etc/fstab
    2. Set the mount option for the root file system (/) to rw.

      修改挂载模式为rw

    3. Press the Esc key, enter :wq, and then press the Enter key to save the change.

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

      reboot