Fsck
fsck (file system consistency check) is a command used to check filesystem for consistency errors and repair them on Linux filesystems. This tool is important for maintaining data integrity so should be run regularly, especially after an unforeseen reboot (crash, power-outage).
Usage:
- fsck [-sACVRTNP] [-t fs-optlist] [filesystem] [fs-specific-options]
Filesystem can be either a device's name (e.g. /dev/hda) or its mount point.
fsck run with no options will check all devices in /etc/fstab
It might be neccesary to run fsck from single-user mode if you need to check and restore a possibly damaged filesystem, especially is /usr is to be checked.
fsck is merely a front-end to other more specific file-checkers which are located in /sbin. If it finds out your file system is ext3, it will automatically start fsck.ext3.
Examples
short read
tweedleburg:~ # fsck.ext3 /dev/sdc1 e2fsck 1.40.8 (13-Mar-2008) DATALUX contains a file system with errors, check forced. Pass 1: Checking inodes, blocks, and sizes Error reading block 426426 (Attempt to read block from filesystem resulted in short read) while getting next inode from scan. Ignore error<y>?
This shows a hardware failure - block 426426 should be read, but no data arrived from disk. You can verify this is the case with the command
dd if=/dev/sdc1 of=/dev/null
while looking at the same time to top and vmstat. You will find the dd runs well to a certain point. From that point on, it is waiting for only one block to arrive from the harddisk. One CPU will show near 100% iowait time while vmstat will not show any blocks in. It is especially annoying that you cannot kill dd, because the process is waiting for data to arrive.
Provided by
Most (all?) Linux distributions incorporate this from the [util-linux] project.