fsck command is a file system utility that checks the integrity of a file system and attempts to repair any errors it finds. It can be used to check and repair a file system on a hard disk, USB drive, or any other storage device that uses a file system that is supported by Linux.
fsck can be run on a mounted file system, but it is recommended to run it on an unmounted file system to minimize the risk of data loss.
fsck [options] [device]
To check and repair a file system on the
/dev/sda1 partition, run the following command:
To automatically repair any errors found during the file system check, use the
fsck -a /dev/sda1
To force a file system check even if it appears clean, use the
fsck -f /dev/sda1
The following table lists the available options for the
||Automatically repair any errors found during the file system check.|
||Display verbose output.|
||Force a file system check even if it appears clean.|
||Do not make any changes to the file system.|
||Automatically repair any errors found during the file system check without prompting the user.|
||Interactively repair any errors found during the file system check.|
||Specify the file system type.|
fsckreports errors that it cannot repair, it may be necessary to manually repair the file system or restore data from a backup.
fsckon a mounted file system can cause data loss or corruption. Always unmount the file system before running
fsckreports that it cannot repair a file system, it may be necessary to run it in rescue mode or from a live CD to repair the file system.
fsckcommand is usually run automatically during system boot to check and repair any errors in the file system.
fsckcan be used to check and repair a variety of file systems, including ext2, ext3, ext4, XFS, and ReiserFS.