All Products
Search
Document Center

:Critical files in non-Unix formats on a Linux instance

最終更新日:Apr 17, 2025

If some critical files on a Linux instance are not in the Unix format, you may not be unable to connect to the instance. You can use the instance health diagnostics feature to perform troubleshooting.

Prerequisites

A Linux instance cannot start and is diagnosed by the instance health diagnostics feature. The diagnosis report indicates that critical system files failed the critical system file format check.

Background information

Problem description: A Linux instance cannot be connected to because some of its critical system files are not in the Unix format.

Possible cause: The critical system files were edited on a Windows operating system and then uploaded to the Linux instance, or incorrect operations were performed.

Solution

  1. Connect to the abnormal instance.
    A repair disk is attached to the instance, and you can connect to the instance only by using Virtual Network Console (VNC). For more information, see Connect to an instance by using VNC.
  2. View the mount information of the original system disk on the instance.
    On the repair disk that is temporarily attached to the instance, the file systems of the original system disk of the instance are mounted to a temporary directory. You can use one of the following methods to view the temporary directory:
    • Check the health diagnosis report of the instance for the temporary directory. Example of the temporary directory: /tmp/ecs-offline-diagnose_disk-bp19bspzms79kqse****.
    • Run the mount command on the repair disk to view the temporary directory. For example, if the device name of the original system disk is /dev/vda, run the following command:
      mount | grep /dev/vda
      The following command output is returned:
      /dev/vda1 on /tmp/ecs-offline-diagnose_disk-bp19bspzms79kqse**** type ext4 (rw,relatime)
  3. To change the root directory to the temporary directory where the original system disk of the instance resides and enter the chroot environment, run the chroot command.
    You must go to the temporary directory where the original system disk resides to restore configuration files. For example, if the temporary directory is /tmp/ecs-offline-diagnose_disk-bp19bspzms79kqse****, run the following command:
    chroot /tmp/ecs-offline-diagnose_disk-bp19bspzms79kqse****
  4. In the chroot environment, run the vim command to edit specific files.
    Before you edit the files, take note of the following items:
    • Run the cp command to back up the critical system files that you want to edit.

      For example, to back up the /etc/passwd file on the original system disk of the instance, run the cp /etc/passwd /etc/passwd.bak command.

    • The files that you are editing are all on the original system disk of the abnormal instance. Before you can edit files that are located outside the mount point of the original system disk, you must run the exit command to exit the chroot environment.
    • You are in the chroot environment and therefore do not need to add the /tmp/ecs-offline-diagnose_disk-bp19bspzms79kqse**** path to the command.

      For example, to edit the /etc/passwd file that is located on the original system disk, run the vim /etc/passwd command that does not contain the /tmp/ecs-offline-diagnose_disk-bp19bspzms79kqse**** path.

    vim [$File]
    [$File] specifies the name of the file that is not in the Unix format. In the examples, the /etc/passwd file is used. Run the following command to edit this file:
    vim /etc/passwd
  5. Change the format of the files to Unix.
    1. In each file whose format you want to change to Unix, press Shift+:, set set ff to unix as shown in the following figure, and then press the Enter key.
      unix
    2. Press Shift+:, enter wq, and then press the Enter key to save and close the file.
  6. After the files are restored, exit the chroot environment and check the state of the abnormal instance.
    1. Run the exit command to exit the chroot environment.
    2. Go to the Troubleshooting page in the ECS console. On the Instance Health Diagnosis tab, detach the repair disk from the instance and start the instance.
    3. Connect to the instance and confirm that you are connected to the instance.