Re: Corrupted partitions

Riley Williams (rhw@MemAlpha.CX)
Sun, 27 Jun 1999 16:15:49 +0100 (GMT)


Hi Khimenko.

>>>> Related to this, can I pass on a question I was recently asked:
>>>> How does Linux deal with a corrupted partition where the
>>>> lost+found entry is itself corrupted? Does it even detect that?

>>> Yes, it will detect and fix a corrupted lost+found directory.
>>> E2fsck can even create a lost+found directory if it is missing
>>> (or too badly damaged to recover), and it can allocate new
>>> blocks to lost+found.

>> Hang on! In an earlier email, you said that the reason that mke2fs
>> preallocates 12 blocks to lost+found is because e2fsck has
>> problems allocating blocks when fixing a corrupted file system,
>> but now you state that no such problem exists !!! Which is it?

> e2fsck CAN create lost+found and extend if it's needed. But it
> can destroy files on corrupted filesystem (there are no easy way
> to chose free block if filesystem is corrupted). So better not
> to try it if possible. But if there are no lost+found or
> lost+found is corrupted then the only choice remains: to detect
> and fix corrupted lost+found or to create new one if there are
> no lost+found at all (or it's to badly dmanage to recover).

Obviously I'm missing something important, so for my peace of mind,
can somebody please tell me where my thoughts are wondering off the
rightful path!!!

As I see things, fsck SHOULD work something along the following lines:

1. Does a scan of this disk indicate that any corruption is
present? If not, finish.

2. Since there is the likelihood of corruption being present, we
can't trust the free list, so ignore it and build a valid free
list IN MEMORY ONLY, listing only blocks for which we can't
find anything using them.

3. Does lost+found exist? If not, go to step 6.

4. Is lost+found corrupt? If not, go to step 7.

5. Rename the corrupt lost+found to a unique name that indicates
that it was the old lost+found directory. Go to step 6.

6. Create a new lost+found directory, allocating blocks from the
in-memory free list generated in step (2). Go to step 7.

7. At this stage, we have a possibly corrupted file system with a
known valid lost+found directory. Go to step 8.

8. If we renamed the old lost+found directory in step (5) above,
process its contents, placing the corrected entries in the new
lost+found directory, then delete the renamed directory. Go to
step 9.

9. Process the rest of the partition, as per usual. Go to step 10.

10. Generate a fresh free list from the results, and write it to
the partition. Finish.

Given the opinions expressed so far, there's obviously something
seriously wrong with that outline, but I can't see what...

> Simple, no ?

Apparently not.

Best wishes from Riley.

+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* ftp://ftp.MemAlpha.cx/pub/rhw/Linux
* http://www.MemAlpha.cx/kernel.versions.html

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/