NetBSD Problem Report #20977

Received: (qmail 29264 invoked by uid 605); 2 Apr 2003 02:51:32 -0000
Message-Id: <200304020251.h322pUl10412@knox.mines.edu>
Date: Tue, 1 Apr 2003 19:51:30 -0700 (MST)
From: jbernard@mines.edu
Sender: gnats-bugs-owner@netbsd.org
Reply-To: jbernard@mines.edu
To: gnats-bugs@gnats.netbsd.org
Subject: /usr/sbin/installboot fails on alternative disks
X-Send-Pr-Version: 3.95

>Number:         20977
>Category:       bin
>Synopsis:       /usr/sbin/installboot fails on alternative disks
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lukem
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 02 02:52:01 +0000 2003
>Closed-Date:    Sun Apr 20 00:38:56 +0000 2003
>Last-Modified:  Sun Apr 20 00:39:00 +0000 2003
>Originator:     Jim Bernard
>Release:        NetBSD 1.6I
>Organization:
>Environment:
System: NetBSD knox 1.6I NetBSD 1.6I (KNOX-$Revision: 1.20 $) #0: Sun Oct 13 19:57:00 MDT 2002 jim@roc:/wd1/var/tmp/compile/sys/arch/sparc/compile/KNOX sparc
Architecture: sparc
Machine: sparc
>Description:
	I wanted to install fresher boot blocks on a second disk on a
	sparc 20, but the MI installboot refused to install them if the
	secondary boot code was anyplace but root, which of course it
	isn't if you're installing on a second disk.  I don't know for
	sure whether this would also happen on other ports with MI
	installboot, but I expect so.

>How-To-Repeat:
	Copy the system to an alternative disk, here assumed to have its
	root partition on sd2a.  Then, in single-user mode:

	  mount /dev/sd2a /altdisk
	  cp -p /altdisk/usr/mdec/boot /altdisk/boot
	  /altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /altdisk/boot

	The response from installboot is:

	  File system:         /dev/rsd2a
	  File system type:    ffs (blocksize 8192, needswap 0)
	  Primary bootstrap:   /altdisk/usr/mdec/bootxx
	  Secondary bootstrap: /altdisk/boot
	  installboot: The secondary bootstrap `altdisk/boot' must be in /
	  installboot: Set bootstrap operation failed

>Fix:
	A workaround is to boot with -a and specify the alternative disk
	as the root device.  This might fail if the kernel and init aren't
	compatible, but I guess you can specify an alternative init, too.
	But it shouldn't have to be done this way.

	The section of the code that does the check (in ffs.c) begins with:

	  /* The secondary bootstrap must be clearly in /. */

	which is wrong, given that one frequently wants to install boot
	code on a disk other than the one that was booted (e.g., when
	first installing from a floppy).  I would recommend either simply
	deleting the check or adding a command-line option to override it.
	My vote would be for the former.  But as long as I can install boot
	blocks anywhere I want without having to stand on my head and form
	a pretzel, I'll be happy.
>Release-Note:
>Audit-Trail:

From: Luke Mewburn <luke@mewburn.net>
To: jbernard@mines.edu
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/20977: /usr/sbin/installboot fails on alternative disks
Date: Wed, 2 Apr 2003 13:13:28 +1000

 On Tue, Apr 01, 2003 at 07:51:30PM -0700, jbernard@mines.edu wrote:
   | 	Copy the system to an alternative disk, here assumed to have its
   | 	root partition on sd2a.  Then, in single-user mode:
   | 
   | 	  mount /dev/sd2a /altdisk
   | 	  cp -p /altdisk/usr/mdec/boot /altdisk/boot
   | 	  /altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /altdisk/boot

 Did you instead try:
 	/altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /boot

 (Since the "secondary boot file" argument is relative to the root of
 the file system you're installboot-ing too).

 Luke.

From: Jim Bernard <jbernard@mines.edu>
To: Luke Mewburn <luke@mewburn.net>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/20977: /usr/sbin/installboot fails on alternative disks
Date: Tue, 1 Apr 2003 21:29:31 -0700

 On Wed, Apr 02, 2003 at 01:13:28PM +1000, Luke Mewburn wrote:
 > On Tue, Apr 01, 2003 at 07:51:30PM -0700, jbernard@mines.edu wrote:
 >   | 	Copy the system to an alternative disk, here assumed to have its
 >   | 	root partition on sd2a.  Then, in single-user mode:
 >   | 
 >   | 	  mount /dev/sd2a /altdisk
 >   | 	  cp -p /altdisk/usr/mdec/boot /altdisk/boot
 >   | 	  /altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /altdisk/boot
 > 
 > Did you instead try:
 > 	/altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /boot
 > 
 > (Since the "secondary boot file" argument is relative to the root of
 > the file system you're installboot-ing too).

   No, that never occurred to me.  With the old MD installboot, I always
 used the equivalent of:

   /altdisk/usr/mdec/installboot -v /altdisk/boot /altdisk/usr/mdec/bootxx /dev/rsd2a

 so it seemed reasonable to suppose that the MI installboot would behave
 similarly (except for the scrambled arguments).  I don't see anything in
 the man page that suggests that the name of the secondary boot file should
 be a path name relative to the target file system.  Am I missing something?

 Doesn't it also seem more intuitive, if you're specifying what looks like
 a full path name (/boot) that it really be a full path name relative to
 the existing directory structure?  I would feel "safer" saying just "boot"
 rather than "/boot" when doing potentially dangerous things like updating
 boot blocks, if the name is going to be interpreted by installboot to refer
 to a file relative to the target file system rather than a path relative to
 the current directory structure.

 I suppose it's too late to change the behavior of MI installboot, but
 it seems like the behavior should be clearly documented, especially since
 it differs from that of the old sparc MD installboot and, to me at least,
 it doesn't seem intuitively obvious.

 Thanks for responding.

 --Jim

From: Luke Mewburn <luke@mewburn.net>
To: Jim Bernard <jbernard@mines.edu>
Cc: Luke Mewburn <luke@mewburn.net>, gnats-bugs@gnats.netbsd.org
Subject: Re: bin/20977: /usr/sbin/installboot fails on alternative disks
Date: Wed, 2 Apr 2003 14:33:48 +1000

 On Tue, Apr 01, 2003 at 09:29:31PM -0700, Jim Bernard wrote:
   | On Wed, Apr 02, 2003 at 01:13:28PM +1000, Luke Mewburn wrote:
   | > On Tue, Apr 01, 2003 at 07:51:30PM -0700, jbernard@mines.edu wrote:
   | >   | 	Copy the system to an alternative disk, here assumed to have its
   | >   | 	root partition on sd2a.  Then, in single-user mode:
   | >   | 
   | >   | 	  mount /dev/sd2a /altdisk
   | >   | 	  cp -p /altdisk/usr/mdec/boot /altdisk/boot
   | >   | 	  /altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /altdisk/boot
   | > 
   | > Did you instead try:
   | > 	/altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /boot
   | > 
   | > (Since the "secondary boot file" argument is relative to the root of
   | > the file system you're installboot-ing too).
   | 
   |   No, that never occurred to me.  With the old MD installboot, I always
   | used the equivalent of:
   | 
   |   /altdisk/usr/mdec/installboot -v /altdisk/boot /altdisk/usr/mdec/bootxx /dev/rsd2a
   | 
   | so it seemed reasonable to suppose that the MI installboot would behave
   | similarly (except for the scrambled arguments).  I don't see anything in
   | the man page that suggests that the name of the secondary boot file should
   | be a path name relative to the target file system.  Am I missing something?

 installboot deals directly with the file system via the raw device
 your provide, so the lookup of the inode and disk blocks of the
 secondary boot is done "below" the user visible file system.

 Did the syntax I suggest actually work?  If so, we can always improve
 the documentation of the MI installboot to be clearer.


   | Doesn't it also seem more intuitive, if you're specifying what looks like
   | a full path name (/boot) that it really be a full path name relative to
   | the existing directory structure?  I would feel "safer" saying just "boot"
   | rather than "/boot" when doing potentially dangerous things like updating
   | boot blocks, if the name is going to be interpreted by installboot to refer
   | to a file relative to the target file system rather than a path relative to
   | the current directory structure.
   | 
   | I suppose it's too late to change the behavior of MI installboot, but
   | it seems like the behavior should be clearly documented, especially since
   | it differs from that of the old sparc MD installboot and, to me at least,
   | it doesn't seem intuitively obvious.



 Luke.
Responsible-Changed-From-To: bin-bug-people->lukem 
Responsible-Changed-By: perry 
Responsible-Changed-When: Wed Apr 2 06:46:34 PST 2003 
Responsible-Changed-Why:  
Luke is the MI installboot guy 

From: Jim Bernard <jbernard@mines.edu>
To: Luke Mewburn <luke@mewburn.net>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/20977: /usr/sbin/installboot fails on alternative disks
Date: Wed, 2 Apr 2003 16:24:12 -0700

 On Wed, Apr 02, 2003 at 02:33:48PM +1000, Luke Mewburn wrote:
 > On Tue, Apr 01, 2003 at 09:29:31PM -0700, Jim Bernard wrote:
 >   | On Wed, Apr 02, 2003 at 01:13:28PM +1000, Luke Mewburn wrote:
 >   | > On Tue, Apr 01, 2003 at 07:51:30PM -0700, jbernard@mines.edu wrote:
 >   | >   | 	Copy the system to an alternative disk, here assumed to have its
 >   | >   | 	root partition on sd2a.  Then, in single-user mode:
 >   | >   | 
 >   | >   | 	  mount /dev/sd2a /altdisk
 >   | >   | 	  cp -p /altdisk/usr/mdec/boot /altdisk/boot
 >   | >   | 	  /altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /altdisk/boot
 >   | > 
 >   | > Did you instead try:
 >   | > 	/altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /boot
 >   | > 
 >   | > (Since the "secondary boot file" argument is relative to the root of
 >   | > the file system you're installboot-ing too).
 >   | 
 >   |   No, that never occurred to me.  With the old MD installboot, I always
 >   | used the equivalent of:
 >   | 
 >   |   /altdisk/usr/mdec/installboot -v /altdisk/boot /altdisk/usr/mdec/bootxx /dev/rsd2a
 >   | 
 >   | so it seemed reasonable to suppose that the MI installboot would behave
 >   | similarly (except for the scrambled arguments).  I don't see anything in
 >   | the man page that suggests that the name of the secondary boot file should
 >   | be a path name relative to the target file system.  Am I missing something?
 > 
 > installboot deals directly with the file system via the raw device
 > your provide, so the lookup of the inode and disk blocks of the
 > secondary boot is done "below" the user visible file system.

   So, I wonder how it ever worked with the sparc MD installboot.  I have notes
 showing that I've done it that way for many years.  Did the MD version work
 differently?  Or did it just strip off any initial path components if they
 were present?

 > Did the syntax I suggest actually work?  If so, we can always improve
 > the documentation of the MI installboot to be clearer.

   OK, I tried it with just "/boot" and it did work.  So, at least the nature
 of the specification of the secondary boot file should be described in the
 man page.  But, would it be OK to omit the leading slash (which would tend
 to lead one to expect it to be a full path name)?  Or even better, how about
 this: the MD installboot on i386 actually copies the secondary boot file over
 to the target file system, so you don't ever have to be bothered with the
 specification of the file in its final resting place.  Could the MI installboot
 do that too?  It would save a step and simplify the installboot command
 itself (at least the interpretation of its arguments).  As well, it would
 make installboot more complete, since it would handle both stages of the
 boot code at once, reducing the distinction between ports that boot in
 a single stage (I assume there are some) and those that use a two-stage
 boot process.

 >   | Doesn't it also seem more intuitive, if you're specifying what looks like
 >   | a full path name (/boot) that it really be a full path name relative to
 >   | the existing directory structure?  I would feel "safer" saying just "boot"
 >   | rather than "/boot" when doing potentially dangerous things like updating
 >   | boot blocks, if the name is going to be interpreted by installboot to refer
 >   | to a file relative to the target file system rather than a path relative to
 >   | the current directory structure.
 >   | 
 >   | I suppose it's too late to change the behavior of MI installboot, but
 >   | it seems like the behavior should be clearly documented, especially since
 >   | it differs from that of the old sparc MD installboot and, to me at least,
 >   | it doesn't seem intuitively obvious.

   Thanks.

 --Jim

From: Jim Bernard <jbernard@mines.edu>
To: Luke Mewburn <luke@mewburn.net>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/20977: /usr/sbin/installboot fails on alternative disks
Date: Wed, 2 Apr 2003 16:24:44 -0700

 On Wed, Apr 02, 2003 at 02:33:48PM +1000, Luke Mewburn wrote:
 > On Tue, Apr 01, 2003 at 09:29:31PM -0700, Jim Bernard wrote:
 >   | On Wed, Apr 02, 2003 at 01:13:28PM +1000, Luke Mewburn wrote:
 >   | > On Tue, Apr 01, 2003 at 07:51:30PM -0700, jbernard@mines.edu wrote:
 >   | >   | 	Copy the system to an alternative disk, here assumed to have its
 >   | >   | 	root partition on sd2a.  Then, in single-user mode:
 >   | >   | 
 >   | >   | 	  mount /dev/sd2a /altdisk
 >   | >   | 	  cp -p /altdisk/usr/mdec/boot /altdisk/boot
 >   | >   | 	  /altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /altdisk/boot
 >   | > 
 >   | > Did you instead try:
 >   | > 	/altdisk/usr/sbin/installboot -v -m sparc /dev/rsd2a /altdisk/usr/mdec/bootxx /boot
 >   | > 
 >   | > (Since the "secondary boot file" argument is relative to the root of
 >   | > the file system you're installboot-ing too).
 >   | 
 >   |   No, that never occurred to me.  With the old MD installboot, I always
 >   | used the equivalent of:
 >   | 
 >   |   /altdisk/usr/mdec/installboot -v /altdisk/boot /altdisk/usr/mdec/bootxx /dev/rsd2a
 >   | 
 >   | so it seemed reasonable to suppose that the MI installboot would behave
 >   | similarly (except for the scrambled arguments).  I don't see anything in
 >   | the man page that suggests that the name of the secondary boot file should
 >   | be a path name relative to the target file system.  Am I missing something?
 > 
 > installboot deals directly with the file system via the raw device
 > your provide, so the lookup of the inode and disk blocks of the
 > secondary boot is done "below" the user visible file system.

   So, I wonder how it ever worked with the sparc MD installboot.  I have notes
 showing that I've done it that way for many years.  Did the MD version work
 differently?  Or did it just strip off any initial path components if they
 were present?

 > Did the syntax I suggest actually work?  If so, we can always improve
 > the documentation of the MI installboot to be clearer.

   OK, I tried it with just "/boot" and it did work.  So, at least the nature
 of the specification of the secondary boot file should be described in the
 man page.  But, would it be OK to omit the leading slash (which would tend
 to lead one to expect it to be a full path name)?  Or even better, how about
 this: the MD installboot on i386 actually copies the secondary boot file over
 to the target file system, so you don't ever have to be bothered with the
 specification of the file in its final resting place.  Could the MI installboot
 do that too?  It would save a step and simplify the installboot command
 itself (at least the interpretation of its arguments).  As well, it would
 make installboot more complete, since it would handle both stages of the
 boot code at once, reducing the distinction between ports that boot in
 a single stage (I assume there are some) and those that use a two-stage
 boot process.

 >   | Doesn't it also seem more intuitive, if you're specifying what looks like
 >   | a full path name (/boot) that it really be a full path name relative to
 >   | the existing directory structure?  I would feel "safer" saying just "boot"
 >   | rather than "/boot" when doing potentially dangerous things like updating
 >   | boot blocks, if the name is going to be interpreted by installboot to refer
 >   | to a file relative to the target file system rather than a path relative to
 >   | the current directory structure.
 >   | 
 >   | I suppose it's too late to change the behavior of MI installboot, but
 >   | it seems like the behavior should be clearly documented, especially since
 >   | it differs from that of the old sparc MD installboot and, to me at least,
 >   | it doesn't seem intuitively obvious.

   Thanks.

 --Jim

From: Luke Mewburn <luke@mewburn.net>
To: Jim Bernard <jbernard@mines.edu>
Cc: Luke Mewburn <luke@mewburn.net>, gnats-bugs@gnats.netbsd.org
Subject: Re: bin/20977: /usr/sbin/installboot fails on alternative disks
Date: Thu, 3 Apr 2003 09:56:36 +1000

 On Wed, Apr 02, 2003 at 04:24:12PM -0700, Jim Bernard wrote:
   |   So, I wonder how it ever worked with the sparc MD installboot.
   | I have notes showing that I've done it that way for many years.
   | Did the MD version work differently? Or did it just strip off any
   | initial path components if they were present?

 It appears that the sparc MD installboot used the inode it found via
 stat(2)ing the file in the mounted file system, and then searching
 for that inode in the raw file system's ffs data structures.


   | > Did the syntax I suggest actually work?  If so, we can always improve
   | > the documentation of the MI installboot to be clearer.
   | 
   |   OK, I tried it with just "/boot" and it did work. So, at least the
   | nature of the specification of the secondary boot file should be
   | described in the man page.

 Fine, we'll do that.


   | But, would it be OK to omit the leading slash (which would tend
   | to lead one to expect it to be a full path name)?

 That is supported.  The leading `/' is optional.  We could remove that
 from the examples, and tweak the documentation to suit.


   | Or even better, how about this: the MD installboot on i386 actually
   | copies the secondary boot file over to the target file system, so
   | you don't ever have to be bothered with the specification of the
   | file in its final resting place. Could the MI installboot do that
   | too? It would save a step and simplify the installboot command
   | itself (at least the interpretation of its arguments). As well, it
   | would make installboot more complete, since it would handle both
   | stages of the boot code at once, reducing the distinction between
   | ports that boot in a single stage (I assume there are some) and
   | those that use a two-stage boot process.

 I don't want to add support to the MI installboot to be able to
 actually manipulate a file system (or file system image) other than
 the boot area / superblock.  Doing any more than that would either
 put too much knowledge of the file system into installboot, or require
 support from the kernel and/or root privileges, and that wouldn't work
 for file system images.

 It is important that installboot works in a cross-friendly manner,
 without requiring special privileges or kernel support, to do its
 work.

 The i386 installboot is Wrong, and needs to be modified to at a
 minimum work how the sparc does (hard code the blocks of /boot
 into the first stage), or even better, how the alpha does (stage1
 has code to search for /boot dynamically at boot time).
 If possible, we'd like to move more platforms to the "alpha method",
 since that allows you to upgrade the /boot stage2 without having to
 re-run installboot.


 Luke.

From: Jim Bernard <jbernard@mines.edu>
To: Luke Mewburn <luke@mewburn.net>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/20977: /usr/sbin/installboot fails on alternative disks
Date: Wed, 2 Apr 2003 19:11:00 -0700

 On Thu, Apr 03, 2003 at 09:56:36AM +1000, Luke Mewburn wrote:
 >   | > Did the syntax I suggest actually work?  If so, we can always improve
 >   | > the documentation of the MI installboot to be clearer.
 >   | 
 >   |   OK, I tried it with just "/boot" and it did work. So, at least the
 >   | nature of the specification of the secondary boot file should be
 >   | described in the man page.
 > 
 > Fine, we'll do that.

   OK.

 >   | But, would it be OK to omit the leading slash (which would tend
 >   | to lead one to expect it to be a full path name)?
 > 
 > That is supported.  The leading `/' is optional.  We could remove that
 > from the examples, and tweak the documentation to suit.

   Good.  Let me know if you'd like me to review any doc changes.

 >   | Or even better, how about this: the MD installboot on i386 actually
 >   | copies the secondary boot file over to the target file system, so
 >   | you don't ever have to be bothered with the specification of the
 >   | file in its final resting place. Could the MI installboot do that
 >   | too? It would save a step and simplify the installboot command
 >   | itself (at least the interpretation of its arguments). As well, it
 >   | would make installboot more complete, since it would handle both
 >   | stages of the boot code at once, reducing the distinction between
 >   | ports that boot in a single stage (I assume there are some) and
 >   | those that use a two-stage boot process.
 > 
 > I don't want to add support to the MI installboot to be able to
 > actually manipulate a file system (or file system image) other than
 > the boot area / superblock.  Doing any more than that would either
 > put too much knowledge of the file system into installboot, or require
 > support from the kernel and/or root privileges, and that wouldn't work
 > for file system images.

   But doesn't it already have to understand the file system in order to
 locate the secondary boot file there?  Is it significantly harder also
 to copy the file there?

 > It is important that installboot works in a cross-friendly manner,
 > without requiring special privileges or kernel support, to do its
 > work.

   That's important, sure.

 > The i386 installboot is Wrong, and needs to be modified to at a
 > minimum work how the sparc does (hard code the blocks of /boot
 > into the first stage), or even better, how the alpha does (stage1
 > has code to search for /boot dynamically at boot time).
 > If possible, we'd like to move more platforms to the "alpha method",
 > since that allows you to upgrade the /boot stage2 without having to
 > re-run installboot.

   That would be very nice, but my impression is that the 512 byte
 constraint on i386 makes that extremely difficult.  Has anyone come up
 with a promising strategy for squeezing the necessary code into that
 small space or working around the constraint somehow?

 --Jim

From: Luke Mewburn <luke@mewburn.net>
To: Jim Bernard <jbernard@mines.edu>
Cc: Luke Mewburn <luke@mewburn.net>, gnats-bugs@gnats.netbsd.org
Subject: Re: bin/20977: /usr/sbin/installboot fails on alternative disks
Date: Thu, 3 Apr 2003 12:34:07 +1000

 On Wed, Apr 02, 2003 at 07:11:00PM -0700, Jim Bernard wrote:
   | >   | Or even better, how about this: the MD installboot on i386 actually
   | >   | copies the secondary boot file over to the target file system, so
   | >   | you don't ever have to be bothered with the specification of the
   | >   | file in its final resting place. Could the MI installboot do that
   | >   | too? It would save a step and simplify the installboot command
   | >   | itself (at least the interpretation of its arguments). As well, it
   | >   | would make installboot more complete, since it would handle both
   | >   | stages of the boot code at once, reducing the distinction between
   | >   | ports that boot in a single stage (I assume there are some) and
   | >   | those that use a two-stage boot process.
   | > 
   | > I don't want to add support to the MI installboot to be able to
   | > actually manipulate a file system (or file system image) other than
   | > the boot area / superblock.  Doing any more than that would either
   | > put too much knowledge of the file system into installboot, or require
   | > support from the kernel and/or root privileges, and that wouldn't work
   | > for file system images.
   | 
   |   But doesn't it already have to understand the file system in order to
   | locate the secondary boot file there?  Is it significantly harder also
   | to copy the file there?

 Yes.

 The code to search the root directory of a file system (image) to find
 a given filename, and to get the list of disk blocks consumed by that file,
 is fairly easy.  The "smarter" bootblocks manage to do this quite
 easily.

 Adding support to write an arbitrary file to a given file system (and
 handle all the associated issues such as block allocation, directory
 growth, etc, etc) is far far harder; when I wrote makefs(8) I
 "cheated" and leveraged off the kernel ffs sources, and even that
 was non trivial.

 From a user point of view, if we just fixed the platforms that use the
 "hardcoded stage2 blocks" method to using the "find stage2" method,
 that would be less effort for us and a better user experience as well.


   | > The i386 installboot is Wrong, and needs to be modified to at a
   | > minimum work how the sparc does (hard code the blocks of /boot
   | > into the first stage), or even better, how the alpha does (stage1
   | > has code to search for /boot dynamically at boot time).
   | > If possible, we'd like to move more platforms to the "alpha method",
   | > since that allows you to upgrade the /boot stage2 without having to
   | > re-run installboot.
   | 
   |   That would be very nice, but my impression is that the 512 byte
   | constraint on i386 makes that extremely difficult.  Has anyone come up
   | with a promising strategy for squeezing the necessary code into that
   | small space or working around the constraint somehow?

 (This is tangental to the installboot documentation issue you
 originally raised :)

 It's not relevant.  On the i386 we have:

     *	DOS Master boot record - sector 0 of disk.  We put the multiboot loader
 	here

     *	DOS Partition boot record - sector 0 of NetBSD partition.
 	We put the first part of the "stage1" boot here.

     *	NetBSD disklabel is in sector 1 of NetBSD partition.

     *	Sectors 2..15 of the NetBSD partition are used by the rest
 	of the "stage1" boot.  ffs reserves the first 8KB of any
 	partition for disk label and platform boot area, and we
 	use that area on many platforms (including i386) to store
 	the stage1 boot.


 So, we don't have a 512byte constraint for the i386 stage1; we have
 ~ 7.5KB to play with, and the current i386 boot loader does that.

 The problem with the i386 boot loader at the moment is that there's
 one ELF file ("biosboot.sym" et al) which contains "stage1" and "stage2",
 and /usr/mdec/installboot breaks that up into "stage1 sector 0",
 "stage1 sectors 1..n", and "stage2", and does hairy magic with
 mounting the partition temporarily to copy in stage2, gets the blocks
 by grovelling the underlying ffs data structures, stuffs those into
 the stage1, and writes the stage1 to sectors 0 and 2..15 of the
 partition.

 At a minimum, the i386 should split into "bootxx" (or maybe
 "bootxx_ffs") for the stage1, and "boot" for the stage2, and the
 user copies stage2 in manually before running installboot.  This would
 mean that the i386 could be migrated to the MI installboot, which
 would allow the i386 to be fully cross-buildable.

 Ideally, I want the i386 to work like the "alpha", so that stage1
 has no hard-coded knowledge of the disk blocks of stage2.

 (I've asked David Laight - one of our recent developers with i386 clue
 & enthusiasm - to investigate this project.)

 Luke.
State-Changed-From-To: open->closed 
State-Changed-By: lukem 
State-Changed-When: Sun Apr 20 00:38:33 UTC 2003 
State-Changed-Why:  
I've updated the man page for installboot(8) as discussed. 

From: Luke Mewburn <lukem@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/20977 CVS commit: src/usr.sbin/installboot
Date: Sun, 20 Apr 2003 00:38:32 +0000 (UTC)

 Module Name:	src
 Committed By:	lukem
 Date:		Sun Apr 20 00:38:31 UTC 2003

 Modified Files:
 	src/usr.sbin/installboot: installboot.8

 Log Message:
 Add explicit descriptions of the `filesystem', `primary', and `secondary'
 arguments, including a clarification that `secondary' is relative to the root
 of the filesystem, not a path name to that file if `filesystem' is mounted.
 Resolves PR 20977 from Jim Bernard.


 To generate a diff of this commit:
 cvs rdiff -r1.27 -r1.28 src/usr.sbin/installboot/installboot.8

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.