The system will check the disk before booting, and you can check mannually in case any errors occurs. The post will show you how to check hard disk consistence and repair the disk errors


Table of Contents

  1. 1. Umount the file system
  2. 2. Check if the disk has errors
  3. 3. Repair the file system if any errors
  4. 4. Repair with data loss
  5. Note

1. Umount the file system

1
2
3
4
## umount your file system
sudo umount /data1
## or
sudo umount /dev/sdb1

2. Check if the disk has errors

1
2
3
4
## use xfs_check to check disk errors
sudo xfs_repair -n /dev/sdb1
## for the older version, use xfs_check
sudo xfs_check /dev/sdb1

3. Repair the file system if any errors

1
2
3
4
## use xfs_repair to repair errors
sudo xfs_repair /dev/sdb1
## for the ext series, use fsck
sudo fsck /dev/sdb1

4. Repair with data loss

Finally, if xfs_repair /dev/sdb1 fails, you might use the following to repair the file system with losing some data

1
2
3
4
5
6
#### clear journals
sudo xfs_repair -L /dev/sdb1
#### repair the file system
sudo xfs_repair /dev/sdb1
#### finally check the errors again
sudo xfs_repair -n /dev/sdb1

Note

Execute xfs_metadump /dev/sdb1 to backup the meta data in case repairation fails