Forced Fsck

From SlackWiki
Jump to: navigation, search


A Forced Fsck (forced file check) happens on boot up due to one of three things:

1) The system was not cleanly shutdown previously (you just turned off the power) and the file system was not cleanly un-mounted.
2) The maximum number of sucessive re-boots (re-mounts (mount count)) between fsck checks has been reached (you have reached Maximum Mount Count).
3) A period of time has passed between fscks that exceed the filesystem's last checked criteria.

Manually Forcing a Forced Fsck

To force a check on the next boot, simply create the file '/etc/forcefsck' and reboot:

touch /etc/forcefsck


Bypassing A Forced Fsck

METHOD 1: Increase the Mount Count/Last-checked time span-
The only way to bypass a Forced Fsck is to boot the machine from another boot medium (e.g. a boot CD) and use tune2fs to increase the Maximum Mount Count or the Last-checked Time span.

To increase the Maximum Mount Count: tune2fs -c new_mount_count filesystem
EXAMPLE: tune2fs -c 50 /dev/hda1 - This will cause a fsck after 50 re-mounts.

To increase the Last-checked Time span: tune2fs -i new_time_span filesystem
EXAMPLE: tune2fs -i 3m /dev/hda1 - This will cause a fsck after 3 months.

GOTCHA: If you are running a RAID Array, make sure you load a kernel image that supports RAID when booting! See the RAID Array tips.


METHOD 2: Manually run fsck-
See Bypassing A Hung Forced Fsck instructions below.


Bypassing A Hung Forced Fsck

Sometimes, a forced fsck will occur and may not complete. It may hang or just keep starting over. To (down and dirty) fix this, boot the machine from a bootable disk (3.5" or CD), DO NOT mount the unchecked filesystem and manually run fsck. You may have to run any one of three modes to complete the check:

fsck -f filesystem - Force checking even if the file system seems clean.
fsck -c filesystem - This option causes e2fsck to run the badblocks program to find any blocks which are bad on the filesystem, and then marks them as bad by adding them to the bad block inode. If this option is specified twice, then the bad block scan will be done using a non-destructive read-write test. Be aware that this takes a long time, such as days on large disk with the the double -c set, but it does tend to fix problematic disks when it does complete.
fsck -p filesystem - Automatically repair ("preen") the file system without any questions.
NOTE: filesystem = boot partition (e.g. /dev/hda1)

GOTCHA: If you are running a RAID Array, make sure you load a kernel image that supports RAID when booting! See the RAID Array tips.

After a successful completion of anyone of the above, your filesystem's mount count will be reset to zero and you should be able to boot normally again.