Forrest logo
tool overview
On this page you find all important commands for the CLI tool fsck. If the command you are looking for is missing please ask our AI.

fsck

fsck stands for "file system consistency check," and it is a command line tool primarily used in Unix-like operating systems to repair and verify the integrity of a file system.

  1. It is commonly used when a file system has become corrupted or damaged due to unexpected system crashes, power failures, or other unforeseen events that can cause data corruption.

  2. fsck can be run on a variety of file systems, including ext (ext2, ext3, ext4), XFS, Btrfs, and FAT.

  3. When executed without any arguments or flags, fsck will attempt to check and repair the file system specified in the /etc/fstab entry.

  4. It employs various techniques to analyze the file system structure, such as examining metadata, directory entries, and ensuring the consistency of file data.

  5. fsck can detect and fix various issues like invalid blocks, inodes, or directories, incorrect file linkages, and orphaned data.

  6. It supports interactive mode, where it prompts the user for decisions when encountering errors or inconsistencies.

  7. Depending on the severity of the file system corruption, fsck might take a significant amount of time to complete its repairs.

  8. It is important to note that running fsck on a mounted file system can be dangerous and may lead to further data corruption. It is recommended to unmount the file system or boot into a rescue environment before running fsck.

  9. The ext2, ext3, and ext4 file systems have a backup superblock that fsck uses to restore the file system in case the primary superblock is damaged.

  10. Experienced users often combine fsck with other tools and techniques to better handle file system repairs, such as using the -n flag to perform a dry run or redirecting the output to a log file for further analysis.

List of commands for fsck:

  • fsck:tldr:08d2c fsck: Check filesystem `/dev/sdX` only if it is clean, reporting any damaged blocks and automatically repairing them.
    $ fsck -fy ${-dev-sdX}
    try on your machine
    explain this command
  • fsck:tldr:148ab fsck: Check filesystem `/dev/sdX`, reporting whether it has been cleanly unmounted.
    $ fsck -q ${-dev-sdX}
    try on your machine
    explain this command
  • fsck:tldr:514f8 fsck: Check filesystem `/dev/sdXN`, reporting any damaged blocks.
    $ sudo fsck ${-dev-sdXN}
    try on your machine
    explain this command
  • fsck:tldr:713a2 fsck: Check filesystem `/dev/sdXN`, reporting any damaged blocks and interactively letting the user choose to repair each one.
    $ sudo fsck -r ${-dev-sdXN}
    try on your machine
    explain this command
  • fsck:tldr:a45a9 fsck: Check filesystem `/dev/sdX` only if it is clean, reporting any damaged blocks and interactively letting the user choose to repair each one.
    $ fsck -f ${-dev-sdX}
    try on your machine
    explain this command
  • fsck:tldr:ecc8a fsck: Check filesystem `/dev/sdXN`, reporting any damaged blocks and automatically repairing them.
    $ sudo fsck -a ${-dev-sdXN}
    try on your machine
    explain this command
tool overview