Running fsck

Force a fsck on the next reboot

RHEL 6

shutdown -F -r now does not work anymore so you have to use touch /forcefsck or forcefsck at kernel command line on boot

  • The /fsckoptions file can be used for fsck options
  • You need to make sure the last field from /etc/fstab is not set to 0

RHEL 7

  • At boot time as a kernel command line parameters (does not work for XFS): fsck.mode=force fsck.repair=yes

fsck.mode=

One of "auto", "force", "skip". Controls the mode of operation. The default is "auto", and ensures that file system checks are done when the file system checker deems them necessary. "force" unconditionally results in full file system checks. "skip" skips any file system checks.

fsck.repair=

One of "preen", "yes", "no". Controls the mode of operation. The default is "preen", and will automatically repair problems that can be safely fixed. "yes" will answer yes to all questions by fsck and "no" will answer no to all questions.

These services are started at boot if passno in /etc/fstab for the file system is set to a value greater than zero.

If a file system check fails for a service without nofail, emergency mode is activated, by isolating to emergency.target.

Run fsck in rescue mode

RHEL 6

Method 1

Boot with installation CD in the rescue mode: linux rescue nomount

vgchange -ay VolGroup
fsck.ext4 /dev/VolGroup/lv_root or fsck.ext4 /dev/sda2

Method 2

Append init=/bin/bash to kernel command line at boot

fsck.ext4 /dev/VolGroup/lv_root or fsck.ext4 /dev/sda2

RHEL 7

Method 1

Boot with installation CD in the rescue mode: linux rescue

vgchange -ay /dev/rhel_<hostname>/root
xfs_repair /dev/rhel_<hostname>/root

Method 2

Append rd.break or rw init=/sysroot/bin/sh to kernel command line at boot

umount /sysroot
xfs_repair /dev/rhel_<hostname>/root
init 6

Skip filesystem checks

RHEL 6

During boot, a filesystem check is performed for devices with a positive integer configured in the last column of /etc/fstab by the code in the /etc/rc.d/rc.sysinit file. This file first checks that the fastboot parameter is not set before checks are performed:

f [ -z "$fastboot" -a "$READONLY" != "yes" ]; then

        STRING=$"Checking filesystems"
        echo $STRING
        fsck -T -t noopts=_netdev -A $fsckoptions
        rc=$?

        if [ "$rc" -eq "0" ]; then
                success "$STRING"
                echo
        elif [ "$rc" -eq "1" ]; then
                passed "$STRING"
                echo
        elif [ "$rc" -eq "2" -o "$rc" -eq "3" ]; then
                echo $"Unmounting file systems"
                umount -a
                mount -n -o remount,ro /
                echo $"Automatic reboot in progress."
                reboot -f
        fi
  • Add the fastboot parameter to the end of the kernel line in GRUB, this will skip the filesystem checks entirely.

RHEL 7

  • Add the fsck.mode=skip parameter to the end of the kernel line in GRUB, this will skip the filesystem checks entirely.