Fragmented or Corrupted

how do files get fragmented or corrupted?

Is our shutdown sequence to blame for corrupted files?

Previously, Vinnie wrote in qdn.public.qnx4:

how do files get fragmented or corrupted?

Is our shutdown sequence to blame for corrupted files?

Corruption can occur when you power down while a file
is in an inconsistent state. It can also because by
an Fsys bug, although there are not likely to be too
many of these around these days. Another way to get
corruption is if your media is having problem, or your
driver has bugs.

Fragmentation on the other hand is a normal consequence of
using the file system. There are various factors involved.
The best way to cause fragmentation is to open and close a
file, adding small amounts of data to the end of the file
each time, on a disk that is almost filled. The converse
is also true. To avoid fragmentation, use a disk that has
plenty of extra space and try to pre-allocate the file in
large chunks if you need to expand it.

Once a disk is badly fragmented, you may want to defrag
it. There is no defrag utility for QNX at the moment,
however if you have a large backup disk, such as Jaz
disk, or a secondary hard drive, you can copy your files
off the disk, delete them, and then copy them back. If
you copy off large enough chunks of data, you should be left
with large enough spaces that the files copied back will no
longer be fragemented.


Mitchell Schoenbrun --------- maschoen@pobox.com