Subject: Re: mkfs should clear possible alternate superblocks
To: David Laight <david@l8s.co.uk>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-userlevel
Date: 09/12/2003 11:38:24
On Thu, 11 Sep 2003, David Laight wrote:

> > > DL> >   So instead of hard coding a gazillion magic sector numbers
> > > DL> > to be zapped, why does newfs not just take the easy way and zero
> > > DL> > out the first 255 or so sectors?
> >
> > Actually, how about from 8K in through the first 255 sectors?
>
> The reason for FFSv2 moving its superblock down the filesystem is to
> allow for larger boot code - so you have to assume that there is
> a large boot program in that area.

Then we document that our mkfs will crash the boot code.

How often do you mkfs a file system? Not often, so it doesn't seem that
bad a thing to do.

Also, are you sure that's why it moved? Where was that documented? I was
under the impression that it moved for a different reason.

> > No. Not sure what Windows does. ext2fs only saves the first 2k for boot
> > code.
>
> In that case I'm looking in the wrong place for an ext2fs magic number.
> It also makes booting from ext2fs somewhat tricky!

Yes. mac68k had an issue for a while that it would boot wrong if you had
EXT2FS in the kernel, and you had had Linux on the disk before, it would
find the EXT2FS superblock then try to mount root as ext2fs, even though
you'd overwritten it as an ffs!

> > It skips the first 8k at present, so that the MBR and disklabel can be
> > there (though you'd only have both there on i386 if you made c == d).
>
> It skips 8k for FFSv1 and 64k for FFSv2.  On i386 this skips the
> partition boot code (the MBR is in disk sector 0 and just reads in the
> first sector of the partition).
>
> > > 3.  Which boot code, primary, secondary or tertiary?  [I'm guessing
> > > primary...]
> >
> > Depends. For i386, it's the primary and secondary. Primary is the first
> > sector, secondary sectors 2 through 15.
>
> I'd say it depends on your numbering scheme :-)
> On i386 (and similar) this the code that loads the 'boot' program.

Yes. As I understand i386, there's the MBR code that will say multiboot or
find the first working partition. Then there's the first sector of said
partition which loads the booter in the other sectors, then there's the
guts of bootxx that loads the 'boot' program. :-)

Take care,

Bill