[CentOS] General Linux query

Thu Aug 21 11:32:02 UTC 2008
Brett Serkez <bserkez at gmail.com>

I can only comment from my experience, which is primarily ext2 and ext3.

> 1) How file systeem get corrupted on linux?

I've almost never seen corruption in a Linux file system, the primary
reason is usually a hardware issue, the secondary reason (by far) is
buggy code.

> 2)  why,when and how fsck to be run without lossing data?

fsck can never guarantee data will not be lost, it does the best it
can, which is usually pretty good.  Normally fsck is run in "single
user mode".  If you want to run it manually, you'd bring the system to
single user mode (init 1) or it would run automatically during boot.
There is a counter in the file system as to the last time fsck was
run, during boot if this exceeds a certain vaule, fsck is run.  There
is also a clean shutdown bit which is set during a normal
shutdown/dismount, if this is not se,t which indicates a possible
system crash, fsck is run during system boot.

> 4)  what are all the precaution to be made to prevent file system
> corruption.

Run a "production" distribution such as Redhat/CentOS vs. more of a
bleeding edge distribution such as Fedora.  More than this, assume
there will be data loss or corruption at some point and take
precautions such as running RAID 1, backups and use a UPS to avoid
system crashes or hardware issues in the face of brown or black outs.
Lastly choose a journaling  file system such as ext3, use ext2 for
partitions were performance over consistency is more important.

> 5)  why & when the system will get hanged  and what are all the possible
> reasons?

Usually hardware issues, particularly memory and hard drives.  Most
distributions come with memtest86 so that the hardware's memory can be
thoroughly tested prior to installation of the operating system.