Jan. 21, 2011, 6:29 a.m.
posted by badaboom
The fsck command (short for "file system check" or "file system consistency check") will start the Unix system utility to check the consistency of your file system. Every now and again you might hear a Unix system administrator talking about the need to fsck a hard drive because it is experiencing problems. Hard disks are like light bulbs: They are made to fail and actually have a MTBF (Mean Time Between Failure) associated with them. This just means that like a light bulb, their internal parts will eventually quit and cease to function due to nonstop use and/or damage.
The fsck command is Unix's disk fixer program, and it is used to clean up problems caused by crashes or errant pieces of software. Much like the tools used in Microsoft Windows systems (such as ScanDisk and defrag), you will eventually need to know this command if you are managing and maintaining a Unix system. Most Unix systems fsck their drives on bootup, and the expected result is an analysis report containing the number of files and the fragmentation level of the drive. If you're watching a Unix machine boot, do not be overly concerned if you see fsck report problems. Unix automatically attempts to fix them.
In most cases, fsck will be successful at the repair and fix. After using fsck on the drives, the system restarts the reboot process, which should then bring you to the login prompt. If the drives have serious problems, the automatic fsck exits with the following error message: Run fsck by hand.
If it does, please don't touch anything, and go find a system administrator for help. If you are running this in your lab, then this is also tied to what we just learned; you may be booting in single-user mode and need to run fsck. If you have a crash after booting, you should run fsck from a boot disk, which may be the same ones you used to install Unix or Linux in your lab. In this example, you can run fsck /dev/sda1 (the partition that is showing the errors) and fsck will attempt the fix. fsck will prompt you to find and fix each error so you can see what it is. Again, this is only something you should do in a lab, or as an experienced user.