Repair corrupted filesystem in Ubuntu

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.

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.