If you've ever lost an important file in a hard disk crash, then you know how frustrating the experience can be. Your computer is working fine as you save an important document. When you reboot a few minutes later, the system refuses to come up, leaving you wondering if you'll ever see your files again.
Fortunately, hard disks often die slowly: individual sectors, the smallest unit of data managed by the disk, begin to fail. When the damage is minor, Ubuntu Linux finds and repairs the corruption automatically. If the disk is badly damaged, however, you'll need to repair the bad sectors manually.
Click on the "Applications" menu.
Click on the "Accessories" group.
Click on the "Terminal" application.
Type the command "mount" and press "Enter."
Choose a filesystem to repair. For example, you might choose the filesystem named "/home" if the output from the "mount" command includes this line:
/dev/mapper/vg0-home on /home type ext3 (rw)
Type the "umount" command to unmount the filesystem. To unmount the "/home" filesystem, for example, issue the command "sudo umount /home".
Type the "fsck" command to repair the filesystem. The "fsck" command stands for "file system check"; it scans the disk for bad sectors and labels the ones that aren't working. To run fsck on the /home filesystem, issue the command "sudo fsck /dev/mapper/vg0-home". Replace "/dev/mapper/vg0-home" with the output from your "mount" command, as appropriate.
Type the "mount" command to remount the repaired filesystem. If you repaired the "/home" filesystem, then use the command "sudo mount /home".
If "fsck" complains that the filesystem is clean and doesn't need to be checked for errors, you can invoke the command as "fsck -f" to force it to attempt repairs anyway.
Some filesystems, like the root filesystem, can never be unmounted while the Ubuntu system is running. In order to repair a critical filesystem like this, you must boot into the "live installer" environment of the Ubuntu install CD before attempting these steps.
The "fsck" utility can damage a filesystem that is still mounted. Always make sure that you've unmounted a filesystem before trying to repair it. If you receive a warning that the filesystem is still mounted, don't ignore it!
Ubuntu Linux uses robust "journaling" filesystems like ext3 and ext4. These filesystems store their files in a special way so as to minimize the need to use the "fsck" command. If your filesystems are becoming corrupt even though your system has not crashed, then your disk is likely failing and should be replaced.