All Products
Search
Document Center

:How to check and fix the file systems of Linux instances

Last Updated:Dec 31, 2020

Introduction

This article describes how to check and repair the file systems of Linux instances.

Background

Alibaba Cloud reminds you that:

  • Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.

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

Create a snapshot for all enabled indexes

First, you must create a snapshot for the instance disk to improve its fault tolerance capability. For more information about how to create a snapshot, see create normal snapshots.

  1. Login ECS console, in the left-side navigation pane, click the instance image > Instance.
  2. In the upper-left corner of the top navigation bar, select a region.
  3. Find the target instance and click its instance ID, or in operation column management in the action column to go to the instance details page in the web.
  4. In the left-side navigation pane, click this example disk.
  5. Click disk on the right side of the create snapshot, in the pop-up window, complete the following:
    1. Enter the snapshot name.
    2. Binds one or more tags to the snapshot.
    3. Click create.
  6. In the left-side navigation pane, click this example snapshot can view snapshot tasks.

Check and repair the file system

  1. Log on to a Linux instance:
  2. Run the following command to verify that the file system is not mounted to the system:
    df -h
    Note: if a file system is attached to the system, you can run the umount/dev/vdb1 command at the appropriate business time to unmount the file system.
  3. Run the blkid command to view the file system type. You can perform the following operations to check and repair different file system types:
    • For EXT3 and EXT4 file systems: fsck-y/dev/vdb1
    • For XFS file systems: xfs_repair/dev/vdb1
  4. If the issue is fixed, skip this step. If you have a system disk file system problem, you need to attach the disk to the original instance. For more information, see step 5 of detaching a system disk from a Linux instance and attaching the system disk to another ECS instance as a data disk.
  5. Run the following command to mount the file system:
    mount /dev/vdb1 /mnt
  6. If you run the following command again to check the mounted file system, the message the file system is abnormal still occur, and you can ignore related alerts. For more information, see Redhatissue.
    • For EXT3 and EXT4 file systems: fsck-y/dev/vdb1
    • For XFS file systems: xfs_repair/dev/vdb1

Application scope

  • Elastic Compute Service