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.
fsckis a front-end for the various filesystem checkers (fsck.fstype) available under Linux. In examples below, I’m using
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
-v- verbose output.
You can find all
fsck options in man pages: