This article is from the Frequently Asked Questions for Linux, the Free/Open Source UNIX-like operating system kernel that runs on many modern computer systems. Maintained by David C. Merrill with numerous contributions by others. (v1.0).
A: You need to run e2fsck (or fsck -t ext2 if you have the fsck front end program) with the -a option to get it to clear the dirty flag, and then cleanly unmount the partition during each shutdown.
The easiest way to do this is to get the latest fsck, umount, and shutdown commands, available in Rik Faith's util-linux package (see Where Are the Linux FTP Archives?). You have to make sure that your /etc/rc*/ scripts use them correctly.
NB: Don't try to check a file system that's mounted read/write. This includes the root partition if you don't see
VFS: mounted root ... read-only
at boot time. You must arrange to mount the root file system read/only to start with, check it if necessary, and then remount it read/write. Almost all distributions do this. If your's doesn't, read the documentation that comes with util-linux to find out how to do this.
Note that you need to specify the -n option to mount so it won't try to update /etc/mtab, since the root file system is still read-only, and this will otherwise cause it to fail.