Subject: Re: proposed re-work / unification of boot block installation
To: Izumi Tsutsui <>
From: Luke Mewburn <>
List: tech-kern
Date: 04/30/2002 20:03:14
On Tue, Apr 30, 2002 at 06:34:38PM +0900, Izumi Tsutsui wrote:
  | I'm working on MI installboot for news68k and now it is mostly working,
  | but I have some questions before commiting this.

Feel free to send the code past me for review.

  | 1) Is it worth that native installboot for each port supports
  |    installation of bootstrap for ALL ports?

Yes, it is.

  | I think it is enough to support only native bootstrap
  | because we can use cross-installboot under src/tools/installboot
  | on cross-build.
  | The real problem is that MD part of installboot (i.e. arch/news68k.c etc.)
  | cannot include MD header files under /usr/include/machine.
  | We can include it like:
  | > #include "../../sys/arch/news68k/include/bbinfo.h"
  | but it is a bit ugly.

That also doesn't work when a user doesn't have a full copy of
usr/src/sys/arch, which is a supported configuration.  (I've already
been down that route.)

  | For sun2 (and others), header file which contains struct bbinfo
  | is installed under sys/dev/sun (or sys/dev/dec etc.), but
  | I don't think it is proper place to install because
  | struct bbinfo is not device specific structure but
  | NetBSD's bootstrap specific.

Yes, we probably should combine all the *_bbinfo structures and
associated defines into one header file (sys/bbinfo.h or
sys/bootblock.h or ... ?) instead of dev/sun/sun_boot.h.

  | 2) Is there any port which requires -b option of MI installboot?
  | Currently, -b option of MI installboot is mentioned as following:
  | >     -b bno  Install primary at block number bno instead of the default
  | >             location for the machine and file system type.
  | But for ustarfs (especally install floppies), it should be
  | >     -b bn  Assume that secondary boot is contiguously present with
  | >            initial block number bn.
  | like alpha's installboot.old. In this case, filesystem type
  | should be ignored and specified name of secondary boot
  | will be used only to determine its file size.
  | If there is no port using this option, I'd like to change its behavior.

The alpha, pmax and vax can all use this option to specify where to
place the first stage (primary) boot loader, which can be useful for
multi-boot cd9660 file systems and ustarfs boot floppies.  Other
platforms (e.g, i386, and news68k ?) could use this to specify where
the secondary bootloader is found?

I have some uncommitted patches which adds "raw" as a file system type
(since the file system detection code was committed we need this for
boot floppy ustarfs creation), which matches anything.   I've been
testing using this to build alpha boot floppies using "ustarboot"
(which is a combined primary & secondary bootstrap in one file) and
that works as expected.

The method I used to create the test floppy was something like:
	dd if=/dev/zero of=floppy.img bs=8k count=1
	cp /usr/mdec/ustarboot boot
	cp /some/kernel/netbsd netbsd
	pax -w boot netbsd >> floppy.img
	/usr/sbin/installboot -t raw -m alpha -b 17 floppy.img boot

If I was feeling motivated I'd add a ustarfs backend and that last
command could change to:
	/usr/sbin/installboot -t ustarfs -m alpha floppy.img boot
But that is more effort that I feel like at this moment, because the
"-b 17" trick works for now ;-)

  | Of course, it is better to implement ufstarfs_match() and
  | ustarfs_findstage2() functions for ustarfs images
  | rather than using -b option, but it isn't easy work for me ;-)

`See above' :-)

Once I've got the "raw" support committed, I can review what you've
done for the news68k stuff and consider the <sys/bbinfo.h> (or
whatever) header file idea.


Luke Mewburn  <>
Luke Mewburn     <>
Wasabi Systems - NetBSD hackers for hire
NetBSD - the world's most portable UNIX-like operating system