You can repair a corrupted filesystem with the program “fsck”.The system utility fsck (for “file system check” or “file system consistency check”) is a tool for checking the consistency of a file system in Unix and Unix-like operating systems such as Linux.

Note:-File systems must be unmounted, you cannot repair them while they are running. fsck must ALWAYS be run on an unmounted filesystem. Running fsck on a mounted filesystem can do SEVERE irreparable damage.

A quick fsck options overview:

Many options for fsck exist, but the most important are:
-f which performs a FAST check
-p which fixes minor problems without user interaction
-y which gives permission to correct every problem found
-n which indicates to only search (and not correct) problems

The most simple variant to run fsck is to force fsck on restart, and then restart your system:

sudo touch /forcefsck

The other option is to switch the system to runlevel 1 (which logs-out any users on the system), unmount all partitions. run fsck & repair, remount all drives, increase the runlevel to 3 to finish.

Was this post helpful?