All Products
Search
Document Center

:Check and repair a Linux file system

Last Updated:Apr 15, 2026

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 snapshot and Create snapshot manually.

Procedure

This topic uses /dev/vdb1 as an example to describe how to check and repair a file system.

  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 using Workbench.

    • If the corrupted file system is on a system disk, detach the system disk from the instance, attach it to another instance as a data disk, and then connect to that instance to perform the following operations. For more information, see Best practices for Linux instance data recovery.

      Note

      In the linked document, perform only the first four substeps of Step 3. Do not mount the file system.

  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 the file system is already mounted on the system, you can choose to run the umount /dev/vdb1 command to unmount it during appropriate business hours.

  3. Run the blkid command to check the file system type so that you can run the appropriate check and repair commands.

    • For EXT3 or EXT4 file systems: fsck -y /dev/vdb1

    • For the XFS file system: xfs_repair /dev/vdb1

  4. (Conditionally required) If you repaired a system disk, reattach it to the original instance. For instructions, see Best practices for Linux instance data recovery. If you repaired a data disk, skip 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?

    • For EXT3 and EXT4 file systems: fsck -y /dev/vdb1

    • For the XFS file system: xfs_repair /dev/vdb1