Linux Command – fsck

fsck – check and repair a Linux filesystem

fsck [-lsAVRTMNP] [-r [fd]] [-C [fd]] [-t fstype] [filesystem…] [–] [fs-specific-options]

fsck is used to check and optionally repair one or more Linux filesystems. filesys can be a device name (e.g. /dev/hdc1, /dev/sdb2), a mount point (e.g. /, /usr, /home), or an ext2 label or UUID specifier (e.g. UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root). Normally, the fsck program will try to handle filesystems on different physical disk drives in parallel to reduce the total amount of time needed to check all of them. If no filesystems are specified on the command line, and the -A option is not specified, fsck will default to checking filesystems in /etc/fstab serially. This is equivalent to the -As options.

The exit code returned by fsck is the sum of the following conditions:
0 No errors
1 Filesystem errors corrected
2 System should be rebooted
4 Filesystem errors left uncorrected
8 Operational error
16 Usage or syntax error
32 Checking canceled by user request
128 Shared-library error

The exit code returned when multiple filesystems are checked is the bit-wise OR of the exit codes for each filesystem that is checked.

In actuality, fsck is simply a front-end for the various file system checkers (fsck.fstype) available under Linux. The filesystem-specific checker is searched for in the PATH environment variable. If the PATH is undefined then fallback to “/sbin”.

-s Serialize fsck operations. This is a good idea if you are checking multiple filesystems and the checkers are in an interactive mode.

-A Walk through the /etc/fstab file and try to check all filesystems in one run. This option is typically used from the /etc/rc system initialization file, instead of multiple commands for checking a single filesystem.

-C [fd] Display completion/progress bars for those filesystem checkers (currently only for ext[234]) which support them.

-M Do not check mounted filesystems and return an exit code of 0 for mounted filesystems.

-N Don’t execute, just show what would be done.

-V Produce verbose output, including all filesystem-specific commands that are executed.

-a Automatically repair the filesystem without any questions (use this option with caution).

-r Interactively repair the filesystem.

Published by

Ferdy Mañago

Great Software Ideas, LLC