Hi Richard,
At 00:05 10/07/2001, Richard Russon wrote:
>On 09 Jul 2001 19:50:12 +0100, Anton Altaparmakov wrote:
> > What do people think should be done if a damaged boot sector is found by
> > the TNG NTFS driver but a valid backup boot sector is found?
>
>Just some comments...
>
> > 1. repair the fs silently
>
>Agreed, this is a bad idea. All repairs should be the jobs of chkdsk.
Ok. Already removed in my local cvs tree. Will commit shortly. But I don't
agree about "all repairs", see end of message.
> > 2. use the backup one and attempt to mount.
>
>I'd like to think of it not as "might find some invalid data", but instead
>"might be able to recover at least something". This really is necessary
>to recover anything we can from a damaged fs.
Yes, but the driver shouldn't worry about that kind of damage. A to be
written ntfsck should do recovery not the driver, I think we agree on that
from your comments on point 1, above.
>ext2 for example will allow you to use a backup superblock for recovery
>purposes. We'd just be doing the same thing.
Yes. So you agree we shouldn't try to use any backups without an explicit
mount option. That saves us from all dangers when mounting, then.
> > mke2fs over NTFS?
>
>Been there, done that. It's interesting to note how LITTLE ext2 needs to
>represent an empty filesystem.
(-: If you think about it NTFS doesn't need that much space either. If you
are talking huge volumes then the overhead is a really small fraction but I
guess ext2 beats NTFS any day (but it's not a journalling fs so the
comparison is unfair).
>Taking things further, how much do we actually NEED to recover data?
>
> $Boot (either of two copies)
> $MFT (need the first six entries (need root dir))
> dot (any valid index allocations are a bonus)
You really need the whole MFT. Anything missing from the mft means trouble.
But the list is shorter: dot is not needed at all. What for? It only
contains copies of info already present in the mft records. Assuming you
have a complete and not corrupt MFT, you can reconstruct a whole NTFS 1.2
volume including the directory tree. If the mft is corrupt then you would
need the directory tree and the bitmap to be able to resolve what is
corrupt and what not... $volume is quite important in that context to know
which ntfs version you are dealing with so you know how to deal with some
structures.
>Things we can live without
>
> $LogFile
> $BadClus
> $UpCase (invalid -> bad collation (not serious))
> $Volume
> $Bitmap (not actually necessary for a read-only driver)
Agreed.
>Then finally there's $AttrDef which we ought to read but don't actually
>take any notice of.
Windows doesn't read the file either as far as I can tell. It is completely
pointless. You only need it to support ntfs volumes of different versions
read-only. But Microsoft has taken the approach of not doing that, either.
Ever tried reading a NTFS 3.x volume using NT 4.0 before SP4? It won't even
boot. Compatibility. Ha! All attributes below 0x1000 are Microsoft owned
(and starting with a $) so they are defined to be certain things and you
can rely on that (well, they did change some attributes but considering
their old counterparts were never used it doesn't really matter). It is
irrelevant what attrdef says about them as this stuff is hard coded into
the Windows driver. - The only advantages of the attrdef I can see is to
check that we stay within the valid size limits for attributes but then
again the only attributes where we need to care are the file name and the
volume name so we can just as well hard code them with a few #defines
somewhere in include/linux/ntfs_fs.h. All the others are either unbounded,
fixed size or we don't ever touch them anyway.
>So give me about 10 clusters of my choice I can give you a filesystem :-)
Yes, that pretty much does it.
>You'd have to make the driver VERY resilient to read complete garbage,
>but thanks to the fixups we can figure out what's safe to read and what
>isn't.
Yes.
> > 3. backup boot sector. run chkdsk to recover
>
>Yeah. Notify the user and don't touch anything.
Yes. That's my preference, too for the backup boot sector. That way we have
maximum safety. And if the user tells the driver to use the backup boot
sector then we _know_ this is a ntfs fs and can start writing/fixing things.
However, I do think the driver needs hotfix capabilities for many things.
For example fixing inconsistencies between mft and mft mirror on mount. Or
do you think the driver should just crash out in some way when it sees that
the fs is corrupt? - I would much rather prefer the driver to try to
recover the fs if possible (and mounted r/w). - The mft mirror mismatch is
I guess something we could give up on and require chkdsk/ntfsck to be run
but that would appear a very silly thing to do. And it gets much harder to
bail out once we have a mounted and functional fs and corruption is
encountered. If the corruption is minor we might very well be able to
recover internally, no need for chkdsk, no need to crash the kernel, just a
warning message that a hotfix was applied.
Having said all that, that could be applied to the boot sector as well. So
if the -o repair option is given on mount or something like that (-o
damaged perhaps is better?), than the driver will do it's best to mount a
damaged fs and recover as much data as possible. This can include fixing
the boot sector. It's not exactly many lines of code for that particular
code...
If we say that kind of stuff is for chdkdsk to do then we can't really
mount a damaged partition at all or we will run into trouble. As you say we
would have to have massive amounts of checks to be able to cope with
complete garbage data... The fixups unfortunately can be fine and the
underlying data can be crap. It happens. Even the windows driver sometimes
causes that kind of corruption to a ntfs volume...
Anton
--
"Nothing succeeds like success." - Alexandre Dumas
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://linux-ntfs.sf.net/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/
|