Repairing a Linux file system using fsck utility This note was created on 2020-06-17 This note was last edited on 2023-01-31 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. === Usage === Warning: Do not run fsck on a mounted file system! "fsck" is a front-end for the various filesystem checkers (fsck._fstype_) available under Linux. In examples below, we use "fsck.ext4". Check and repair file system: # 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: # 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