How to check file system using fsck in linux?

* Fsck is a utility to check and repair the file system inconsistency if there is any improper shutdown or hardware failure.
* Due to this superblock in a file system is not updated, here super block is a record which contains information about the file system type and  size , block size and free blocks , size and location of inode tables and free inodes.

fsck – Modes

Interactive : It examines the file system and it stops is there is an error and ask for the user to respond like correct the problem or continue.

Non interactive : If it finds any problem it will repair automatically. Every time while booting non interactive fsck is run, all error are corrected and if still there is an error then it boots in single user mode and ask the user to run fsck manually to correct the problems in file system.

Running fsck

* If you are running fsck it has to be in single user mode because in normal mode
file system is changing constantly and fsck see the changes as inconsistencies.
* If you are running fsck on partition then it has to be unmounted. running on mounted file system leads to data corruption.
* Running fsck on root / file system boot the computer in rescue mode using installation CD
Single user mode

# init 1
# umount  /home
# fsck  /dev/sda2 OR  # fsck  -t  ext3 /dev/sda2  OR  # fsck.ext3  /dev/sda2
#fsck  -y  /dev/sda2 —- It will not ask for the user permission to continue.
once fsck finished remount the file system
#mount /home

No comments:

Post a Comment