Wednesday, May 23, 2012

Disabling FreeBSD background fsck

If you are familiar with unix systems, you probably know already fsck, if not feel free to take a look at the wikipedia article about it to learn more.

FreeBSD has a nice feature in its UFS2 filesystem called background fsck, which allow dirty filesystems (filesystems that hadn't been unmounted properly/cleanly) to be mounted even if they need fsck to check them. Once mounted, a fsck process is started in the background, checking that partition.

This is really nice because your server will not took ages to reboot after a crash, because of fsck running before finishing the boot process (before mounting the partitions exactly). You can learn more about background fsck in this article from Kirk McKusick.

But, background fsck could be a problem in certain situations. For example, it happened to one of my servers this week that, after some crashes the server just reboot fine, then started the backgrounds fsck. It went ok for a while, but when fsck is called to run on the biggest partition (600Gb, mounted in /home, with probably 45% of the space used) the machine crashed again (kernel panic).

That server is a high-load mail server with a lot of disk writes, so I thought that perhaps disabling the background fsck feature could help. It would be even better if I could get the machine to perform an offline fsck by itself and then boot cleanly (yes, that was background fsck is supposedly to avoid).

To do it I added these two lines to /etc/rc.conf:

fsck_y_enable="YES"
background_fsck="NO"

The first one sets yes as the default answer for all the questions fsck could make during a check, while the second one disables the background fsck feature.

Then I rebooted the server, and it took quite a while to finish the reboot, but the filesystems were clean and the machine didn't freeze anymore.

(Hope it helps any of you).

Reference:
http://blog.e-shell.org/266

No comments: