fsck in CentOS 5.x howto

fsck is used to check and optionally repair one or more Linux file systems. File system can be a device name (e.g. /dev/sda2), a mount point (e.g. /, /usr,… ), or an ext2 label or UUID specifier. By default, the fsck will try to handle filesystems on different physical disk drives in parallel to reduce the total amount of time needed to check all of the filesystems.

I hope you won’t need this instructions but in case you have some problems …

First, keep in mind that running fsck on a mounted file system can result in data corruption so use this commands at your own risk. I’m not responsible for any damage you may cause.

To avoid this, you can:

  • Change the running state of the system to single user mode and unmount the file system
  • (Note: Skip this option if you need to check / part.)

  • Boot the computer into Rescue Mode using the installation CD

1) Single user mode

Change the run level to 1 and unmont the file system with (I suppose the /home was affected with problems)

# init 1
# umount /home

Then run fsck with

# fsck /dev/sda2

2) Rescue mode with install CD

Insert the Installation CD into the drive and reboot your system with

# reboot

Wait a while and after booting from the Installation CD type in command prompt:

# linux rescue nomount

Note: nomount directive will skip mounting so you can safely run fsck on your filesystem

Then enter

# fsck -yvf /dev/sda2

where /dev/sda2 is problematic partition.
Note: -yvf means
-y attempt to fix any detected filesystem corruption automatically (answer all questions with “yes”)
-f force a check even if reported in a clean state
-v verbose output, including all file system-specific commands that are executed (you will see all errors and recovery process)

LVM Partitions
Situation with LVM partitions is a little different. To run fsck on lvm partitions first you need to find the pv’s, vg’s, lv’s and then to activate them.

# lvm pvscan
# lvm vgscan
# lvm lvchange -ay VolGroup00
# lvm lvscan
# fsck -yfv /dev/VolGroup00/LogVol00

fsck can be scheduled on boot with

# shutdown -Fr now

1 thought on “fsck in CentOS 5.x howto

Leave a Reply

Your email address will not be published. Required fields are marked *