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.
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.
NoteIn the linked document, perform only the first four substeps of Step 3. Do not mount the file system.
Run the following command to check whether file systems are mounted on the system. Make sure that no file systems are mounted.
df -hNoteIf the file system is already mounted on the system, you can choose to run the
umount /dev/vdb1command to unmount it during appropriate business hours.Run the
blkidcommand 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/vdb1For the XFS file system:
xfs_repair /dev/vdb1
(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.
Run the following command to mount the file systems:
mount /dev/vdb1 /mntRerun 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/vdb1For the XFS file system:
xfs_repair /dev/vdb1