Why fsck runs after every 30 mounts?

Pranab Shenoy pranab.shenoy at gmail.com
Wed Sep 5 22:53:39 UTC 2007


Hi,

I have attached a write up on why the fsck program runs after every 30 disk
mounts. Please have a look and let me know
if any sections need be removed. It a simple text file for now, and I have
yet to convert it to Docbook which I will do only
upon getting approval.

Thanks.

Regards,
Pranab.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-doc/attachments/20070905/72e5b522/attachment.html>
-------------- next part --------------
Why fsck check runs every 30 times?

To answer this question, we must first understand a bit about file systems,
mounting and hard drives. We all know that hard drives are locations in our
computers where we store our data. However the data that actually gets stored
there and the way we perceive it is totally different. We know our files and
folders by human readable names. We want supporting information like
date of creation, size of file and permissions to view the file to be 
maintained too. This is where the filesystem comes into the picture. The 
filesystem is a program that allows users to access, modify, store, organize
and maintain data. It provides an interface that is easily understandable by
us and yet at the same time be able to control and operate the hard disk at a
low level. Finally, mounting is the action which provides physical access to
the hard drive and makes files present on it accessible to users.

With this information let us see why fsck acts the way it does. We know
computers hang all the time. During these situations sometimes the users only
way out is an improper shutdown of the system using a hard reset or simply just
pulling the plug. When this happens the filesystem gets left in a inconsistent
state and the hard drive gets unmounted uncleanly. Reason being that before the
computer hung, there would have been many files opened and various operations
might have been taking place on those open files.

To get a better understanding picture yourself on roller skates. In your hand
are a number of plates, and your in a room with with a number of shelves that 
is used to store these plates. Your job is to take the plates in your hands and
place them in the right shelf. What do you think is gonna happen if some one
switches of the room lights while your at work storing those plates.

Fsck is tasked with fixing up the mess. The best time to fix this mess is when
the computer starts up next, before the hard drive gets mounted again and
users have read write permission to it. Fsck being run in such a situation
can take anywhere between a few minutes to hours depending on how bad the mess
is. However this was in the old days when we were using the ext2 file system.

Nowadays most Ubuntu users use the ext3 file system, which is similar to the
ext2 but has an added feature called journaling. Journaling makes recovery
from unceremonious reboot much easier and faster and most times nowadays
fsck is almost never run after a system crash, because journaling takes care
of the filesystem recovery. However this does not mean that fsck is unwanted.
Fsck provides a much more thorough filesystem check and repair. This is the
reason why regardless of whether your system crashed and rebooted or your
just powering up your system after the last clean shutdown, fsck still needs
to be run from time to time check the integrity of your filesystem. This is
just good practice, since we all know "prevention is better than cure".

Lastly there is no compelling reason that the check has to be done after 30
mounts only. That value can be changed using a program called tune2fs. Most
users are not even affected by the number 30 because their systems never
reboot and if they do, it happens very rarely. On the other hand users that
run Ubuntu on systems that are constantly switched on and off, might want to
increase the number to more than 30. Personally I think the number 30 makes
sense if one powers down their system only once a day (like when going to 
sleep). In this case a fsck check at the end of the month is good system
maintenance.

Pranab.





More information about the ubuntu-doc mailing list