SupportTutorialsHow to perform a file system check?

How to perform a file system check?

The file system check is is a practical tool if an error occurs in your file system and your server is not booting any more. With this tool you can analyse and repair such errors in your file system. We recommend to backup all your data before you start with this operation, because there could be data loss of your server during the repair process. Please start the file system check in the rescue system.

If you do not know what the rescue system is or how to start it, please click here.

fsck1

As soon as your server has booted into the rescue system, please use the following command to display all existing partitions.

  • fdisk -l

fsck2

In this example the system partition is located on /dev/vda1. Normally the system partition is located on /dev/sda1 or /dev/vda1.

Please use the following command to check which file system type is used.

INFORMATION: Please use your actual partition, in our case we have to use /dev/vda1

  • blkid | grep vda1 | awk '{print $3}'

fsck5

Depending on which file system is used and which partition has to be checked,  you have to use the following commands. This is only a check in advance and your file system will not be repaired.

  • fsck.ext2 -n /dev/vda1 = For the file system ext2
  • fsck.ext3 -n /dev/vda1 = For the file system ext3
  • fsck.ext4 -n /dev/vda1 = For the file system ext4
  • fsck.btrfs -n /dev/vda1 = For the file system btrfs
  • and so on...

In our case we are using the file system ext4, therefore, we have to use the following command. Please use the command with the right file system type for the rest of the following commands.

  • fsck.ext4 -n /dev/vda1

fsck10

You will get as result the errors of your file system. If you would like to repair scattered errors, so use the following command.

  • fsck.ext4 /dev/vda1

fsck11

If you think that all errors have to be repaired, please use the following command. This command includes the parameter  -y which answers all queries with  "Yes". It is not necessary to answer them manually.

Important: We recommend to use this command only if you are 100 percent sure.  All queries will be accepted without further notification.

  • fsck.ext4 -y /dev/vda1

fsck12

Your system should start normally once the file system check has been finished.

If you would like to exit the rescue system and booting from the regular hard drive, please use the following command.

  • exitrescue && reboot

Your server should will start the operating system now.

Additional important information:

If you start a file system check , some files might lose the information about their names and locations in the file system. The file system check deposits these files in a specific directory called lost+found. If there are missing files after you have performed the file system check, you will be able to find the files in this directory in most cases.

SupportTutorialsHow to perform a file system check?