Re: Ext2 Problem

Andries.Brouwer@cwi.nl
Thu, 18 Apr 1996 12:10:07 +0200


Matthew Lepper:

> There is a bad bug in the ext2 file system, namely the fact
> that the magic number is not stored in the same relative
> position as minix uses. In fact, the minix magic number is
> stored where ext2 stores the number of free inodes.
> Thus, an ext2 file system with one of four different values
> for the number of free inodes will be mounted as minix,
> and no doubt cause lots of complaints.

No doubt. This is a fairly serious problem. I was able to mount
the partition by forcing the the fs type with:
mount -t ext2 /dev/sdb3 /mnt

Is there a fix to force the filesystem type for the root filesystem?

Not yet in 1.3.90. Since it is really necessary to have this
possibility, I suppose Linus will include my patch in one of
the coming kernel patches, code freeze notwithstanding.
It allows you to give a boot option "rootfstype=ext2".
Distributors will want this in lilo.conf, to eliminate this problem.

I don't want to move this machine to 1.3.* to take advantage of
this more recent fix.

Then boot from a boot floppy, mount your filesystem, create an empty
file, and reboot. The number of free inodes must not be one of
4991, 5007, 9320, 9336 (0x137F, 0x138F, 0x2468, 0x2478).

> If you mounted as rootfs then probably the above furnishes the
> explanation. Otherwise, what error message does a recent mount give?

No error message, it just reboots the machine. I tried 1.3.88,
it at least killed the process with a kernel page fault.

Yes, so the kernel minix code (assuming that it is really a minix fs
that the kernel seems to detect) trusts the disk data too much.
I can also mount a DOS disk as ext2, and that gives thousands of
error messages, but no kernel crash.
Someone with too much spare time ought to check the minix code.

Andries

[Offsets for magic numbers are: minix 16, ext[2] 56, xiafs 572,
so other confusions are possible.]