FSCK - File System ChecK

From PCLinuxOSHelp Knowledge Base
Jump to: navigation, search

What is FSCK and what is it for?

The system utility fsck (File System ChecK) is a tool for checking the consistency of a file system in Unix and Unix-like operating systems, like Linux.

When should I run FSCK?

Generally, fsck is ran, either when the operating system detects that a file system is in an inconsistent state, indicating a non-graceful shutdown, such as a crash or power loss; or periodically to prevent small, undetected inconsistencies becoming exacerbated.

Because running fsck to repair a file system which is mounted for read/write operations can potentially cause severe data corruption/loss, the file system should be checked while unmounted.

Filesystem checks need to be done on unmounted filesystems. You could do an fsck from the liveCD on your / partition, as it can't be unmounted from a running system. Your /home partition could be unmounted by root, and checked from a running installed system. Any data partitions could be unmounted and checked from the running system. Your / partition needs to be checked from a different running system, like the liveCD.

How do I run fsck?

Boot from a LiveCD and as the root user in a command/terminal window enter the following

[root@localhost user]# fsck -f /dev/mountpoint

You should see something like this

[root@localhost user]# fsck -f /dev/sdc11
fsck from util-linux 2.22.2
e2fsck 1.42.7 (21-Jan-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdc11: 11/987360 files (0.0% non-contiguous), 104366/3941941 blocks

For more information about fsck run man fsck