Sunday, May 20, 2012

Linux: Skip or Bypass a Fsck

Q. I know how to force fsck on the next reboot using /forcefsck file. But how do I skip or bypass a fsck on reboot? How to stop a FSCK from prompting or running automatically when rebooting server.

A. It is recommended that you run a fsck on reboot if required. Usually, system automatically determines if fsck required or not. Generally, fsck is run automatically at boot time when the system detects that a file system is in an inconsistent state, indicating a non-graceful shutdown, such as a crash or power loss.

Bypass a fsck using shutdown command

When rebooting the server use the following command
# shutdown -rf now
Above command will reboot the system and will not run auto fsck.

Set Linux kernel option by editing grub.conf / menu.lst

Open grub.conf or menu.lst (usually located in /boot),
# vi /boot/grub.conf
Find kernel line and put fastboot at the end of the kernel line. In the end it should look as follow:
kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 fastboot

Skip fsck by updating /etc/fstab file

Finally, you can edit /etc/fstab file which, contains descriptive information about the various file systems. You will see two numbers at the end of the line for each partition, change the second number to a 0 (zero digit). This will have the system mount the partition but will not run a check when booting. The sixth field, is used by the fsck program to determine the order in which filesystem checks are done at reboot time. The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. If the sixth field is not present or zero, a value of zero is returned and fsck will assume that the filesystem does not need to be checked. Here is sample entry:
LABEL=/disk3  /disk3   ext3 defaults 0 0

No comments:

Post a Comment