All Products
Search
Document Center

:Check and repair the file systems on a Linux instance

Last Updated:Jun 05, 2024

This topic describes how to check and repair the file systems on a Linux instance.

Prerequisites

The snapshot service is activated and a system disk snapshot is created. For more information, see Activate ECS Snapshot and Create a snapshot for a disk.

Procedure

In this example, the /dev/vdb1 partition is used to describe how to check and repair the file systems on a Linux instance.

  1. Connect to the Linux instance.

    • If exceptions occurred on the file systems in the /dev/vdb1 partition of a data disk of the instance, directly connect to the instance. For more information, see Connect to a Linux instance by using a password or key.

    • If exceptions occurred on the file systems in the /dev/vdb1 partition of the system disk of the instance, detach the system disk from the instance, attach the disk to another instance as a data disk, and then connect to the newly attached instance to perform the following operations. For more information, see the "Step 2: Detach the system disk from Instance A" and "Step 3: Attach the system disk that was detached from Instance A to Instance B as a data disk" sections of the How do I restore system disk data? topic.

      Note

      When you perform the operations that are described in Step 3: Attach the system disk that was detached from Instance A to Instance B as a data disk, you need to perform only the first four substeps. You do not need to mount file systems.

  2. Run the following command to check whether file systems are mounted on the system. Make sure that no file systems are mounted.

    df -h
    Note

    If file systems are mounted on the system, run the umount /dev/vdb1 command to unmount the file systems during an appropriate period of time.

  3. Run the blkid command to view the file system type. Run one of the following commands to check and repair the file systems based on the file system type:

    • Ext3 and Ext4 file systems: fsck -y /dev/vdb1

    • XFS file systems: xfs_repair /dev/vdb1

  4. (Conditionally required) After you confirm that the file systems are repaired, you must attach the disk to the original instance if the faulty file systems were on the system disk. For more information, see the "Step 5: Re-attach Disk C to Instance A" section of the How do I restore system disk data? topic. If the faulty file systems were on a data disk, ignore this step.

  5. Run the following command to mount the file systems:

    mount /dev/vdb1 /mnt
  6. Rerun one of the following commands to check the mounted file systems. If file system exceptions persist, ignore the alerts. For more information, see Why does fsck show corruption when running 'fsck -n' on a mounted device when the devices are clean?

    • Ext3 and Ext4 file systems: fsck -y /dev/vdb1

    • XFS file systems: xfs_repair /dev/vdb1