This page looks best with JavaScript enabled

How to repair a filesystem using fsck

 ·  ☕ 1 min read

fsck (“file system consistency check”) is a tool for checking the consistency of a file system in Unix and Unix-like operating systems.

fsck generally has three modes of operation:

  • Check for errors, and prompt the user interactively to decide how to resolve individual problems;
  • Check for errors, and attempt to fix any errors automatically;
  • Check for errors, and make no attempt to repair them, but display the errors on standard output.


fsck is a front-end for the various filesystem checkers (fsck.fstype) available under Linux. In examples below, I’m using fsck.ext4.

  • Check and repair file system:

    sudo fsck.ext4 /dev/sdb1 
  • Check file system for errors, but do not attempt to repair them and print any errors to standard output:

    sudo fsck.ext4 -n /dev/sdb1 
  • Check and repair file system; before overwriting a file system block, write the old contents of the block to an undo file:

    sudo fsck.ext4 -v /dev/sdb1 -z /mnt/wd2tb/backup/sdb1undofile.bak
  • Use undo file to undo changes in file system:

    e2undo /mnt/wd2tb/backup/sdb1undofile.bak /dev/sdb1

Additional options

  • -v - verbose output.

All Options

You can find all fsck options in man pages:

man fsck

Vladislav Pashinskikh
Vladislav Pashinskikh
DevOps Engineer, GNU/Linux enthusiast, FOSS and privacy activist from Ukraine