fsck


fsck

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.

Here is what the whole message would look like on some distros of Unix or Linux.

[View full width]

checking root filesystems parallelizing fsck version 1.04 [/sbin/fsck.ext2] fsck.ext2 -a /dev/sda1 /dev/sda1 contains a file system with errors check forced Block 23454345665 of inode 143234 > Blocks (10234234) /dev/sda1: UNEXPECTED INCONSISTENCY; Run fsck manually an error occurred during the file system check. Dropping you to a shell; the system will reboot when you leave the shell

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.



    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net