What is FSCK?

What is FSCK? Why is it required? There are several reasons behind the system file corruption. For example, you forgot to shut down your system properly, suddenly cut off the power supply, a storage device was removed when system is in process to write the data on it, accidentally press the restart button of your system.

In Linux some data is kept in the memory before it is written to the disk. This speeds up the process and it used in many systems including Windows OS. If the system is turned off or improperly shut down before it writes the data from memory to disk then there is a chance of the system file corruption. Hence, it is required to shut down the system properly. During improper shut down, the file systems are unmounted from the memory. FSCK will unmount these file systems during boot automatically. You can also run FSCK program manually using the below command:

To check root file system:
fsck -V -a

For all other than root file systems:
fsck -R -A -V -a

The last command will check everything except root (-R) file systems.

You can also tell fsck to show what it did using echo option as below:

fsck -A -V ; echo ==$?==

The fsck codes are listed in the below table:

Code Explanation
0 No errors
1 File system errors corrected
2 System should be rebooted
4 File system errors left uncorrected
8 Operational error
16 Usage or syntax error
128 Shared library error

Generally, fsck repairs the file systems automatically. If it fails to repair the file systems then you probably have a corrupted superblock.

Kailash Aghera

Leave a Reply