Friday, December 18, 2009

Repair a corrupted filesystem in Ubuntu


You can repair a corrupted filesystem with the program "fsck".Thesystem utility fsck (for "file system check" or "file systemconsistency check") is a tool for checking the consistency of a filesystem in Unix and Unix-like operating systems such as Linux.
Note:-File systems must be unmounted, you cannotrepair them while they are running.So fsck must ALWAYS be run on anUNmounted filesystem.Running fsck on a mounted filesystem can do SEVEREdamage.
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 swich the system to runlevel 1 (logs-out anyuserRunning fsck on a mounted filesystem can do SEVERE damage), unmountall partitions. run fsck & repair, remount all drives, increase therunlevel to 3 and continue. Source: swik.net