Sobes.tech
Middle

How are disks checked? What does the fsck command do?

sobes.tech AI

Answer from AI

Disk checking in Linux usually involves verifying the integrity of the file system and searching for errors. The fsck (file system check) command is used for this purpose.

fsck scans the file system for errors such as corrupted indexes, metadata inconsistencies, lost clusters, etc. When problems are found, it attempts to fix them to prevent data loss and ensure proper disk operation.

Example usage:

sudo fsck /dev/sda1

where /dev/sda1 is the disk partition to be checked.

Important: before running fsck, the partition must be unmounted to avoid data corruption. Usually, the check is performed in recovery mode or during system boot.