What does linux command fsck do? Why & when is it run?

fsck stands for “file system consistency check”. On most systems, fsck is run at boot time if certain conditions are detected. Usually, these conditions are:

  • A file system is marked as “dirty” — its written state is inconsistent with data that was scheduled to be written; or,
  • A file system has been mounted a set number of times without being checked.

The fsck command itself interacts with a matching filesystem-specific fsck command created by the filesystem’s authors. Regardless of filesystem type, 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; or,
  • Check for errors, and make no attempt to repair them, but display the errors on standard output.


fsck -F ufs /dev/rdsk/c0t0d0s0

The exit code returned by fsck is a unique number representing the sum of the following condition values:

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 – Fsck canceled by user request
128 – Shared-library error

Is recommendable that you run the fsck from a boot cdrom.

at the maintenance prompt-> halt
at the prompt (ok) -> boot cdrom -s
then -> fsck -F ufs /dev/rdsk/c0t0d0s0

if you have a BAD SUPERBLOCK message-> 
newfs -Nv /dev/rdsk/c0t0d0s0
(to obtain the block numbers of the Superblock backup’s) 

select a backup block number in the middle of the previus
then run -> 

fsck -F ufs -ob=<backup_block_numer> /dev/rdsk/c0t0d0s0