How to use fsck?
To use fsck the system should be brought down to single user mode. Within single user mode has to be invoked
fsck, providing it the options to force a check of all file systems, even if they are already stable.
Without any arguments, the fsck programme would check only that type of entries in the /etc/fstab which have an entry fspassno (Linux),/etc/vfstab (sun) file which have an entry for the devtofsck field and have a nonzero numeric value entry in the fsckpass field.
Syntax
fsck [options] [ device or mount point ]
Options
A Runs fsck for all the file system,
-N Prints out the help message.
-V (Solaris) Prints the help message.
-t Denotes the file system for that fsck is to be run.
The given syntax fixes and checks the file system in a noninteractive mode and exists instantly if there is a problem that required user's intervention.
Let consider the following example
# fsck /opt
A Running fsck on a mounted filesystem might cause
SEVERE filesystem damage. Do you really want to continue (y/n)? Yes/dev/hda9 was not cleanly unmounted, the check forced.
Pass 1: Checking blocks, inodes, and sizes
Pass 2: Checking directory structure
Pass 3: Checking the directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking the group summary information
Block the bitmap differences: -98858 -98859 -98860 -98861
Fix<y>? yes
Free blocks count wrong for group #12 (7635, counted=7638). Fix<y>? yes
Free blocks count wrong (236509, counted=236413). Fix<y>? yes
/dev/hda9: ***** FILE SYSTEM WAS MODIFIED *****
/dev/hda9: 8422/78312 files (0.8% non-contiguous), 76723/313236 blocks
Checking ufs File Systems For ufs file systems, it is a five-phase process. fsck can automatically make right most of these errors and does so if invoked at boot time to automatically check a dirty file system.