Re: Enhancing cdboot [patch for review]

Previous thread: MAXFILES in subr_param.c by Ivan Voras on Monday, December 8, 2008 - 12:41 pm. (7 messages)

Next thread: Enhancing cdboot [patch for review] by Maxim Sobolev on Monday, December 8, 2008 - 3:40 pm. (1 message)
From: Maxim Sobolev
Date: Monday, December 8, 2008 - 3:40 pm

[Empty message]
From: Luigi Rizzo
Date: Monday, December 8, 2008 - 4:51 pm

[Empty message]
From: Maxim Sobolev
Date: Monday, December 8, 2008 - 5:29 pm

Good idea, I will see if I can put that in. In fact this behavior should 
have to be optional as well, since one of the uses for the "silent" 

No, they are not the same. $LOAD is address where BIOS loads boot 
sector, which is 0x7c00 by default (you can configure it when building 
CD-ROM, which is why it's an option). On the other hand, $start is 

Well, I don't see the reason to hardwire this. CDROM boot code can be of 
different size (within certain limits of course, to be selected when 

Hmm, maybe I misunderstood it then. What do you mean by "point to 
partition entry exactly"? Right now it points to the beginning on MBR.

-Maxim
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: Giorgos Keramidas
Date: Monday, December 8, 2008 - 6:29 pm

Nice pair of features :-)

If there are no pressing space constraints maybe we can build both
options in by default, but still make them opt-out when necessary?

With a bit of makefile glue we can make it possible to compile with an
`src.conf' that includes:

    WITH_CDBOOT_SILENT=1
    WITHOUT_CDBOOT_PROMPT=1

This way the defaults can include support for both options, but we can
conditionally compile *out* the bits that are not needed for some custom
installation.

Something like this can define one or both of these options in CFLAGS,
depending on what `src.conf' contains:

  # When CDBOOT_SILENT is set, the cdboot doesn't produce any messages except
  # "Loading, please wait..." and it also passes RBX_MUTE flag to the next
  # stage to silence it as well. This is intended for custom installations
  # where end-user is not required to see any messages or interfere with the
  # boot process.

  .if ${MK_CDBOOT_SILENT} != "no"
  CFLAGS+= -DCDBOOT_SILENT
  .endif

  # When CDBOOT_PROMPT is enabled the cdboot behaves like windows xp or vista
  # cd loader, that is it reads MBR from the first hard drive in the system
  # and if the MBR is bootable (i.e. drive has some other operating system
  # installed on it) then it presents user with "Press any key to boot from
  # CD" prompt and waits for 20 seconds. If key is not pressed then the
  # control is passed to the MBR, otherwise CD is booted. This is intended for
  # installation CD to allow unattended mode and also helps when installation
  # CD has been unintentionally left in the drive of the machine that is set
  # to boot off CD.

  .if ${MK_CDBOOT_PROMPT} != "no"
  CFLAGS+= -DCDBOOT_PROMPT
  .endif

The defaults for ${MK_CDBOOT_XXX} will have to be explicitly set in
`src/share/mk/bsd.own.mk', near line 281:

    281 #
    282 # MK_* options which default to "yes".
    283 #
    284 .for var in \
    ...

But that shouldn't be a problem, AFAICT ...
From: Luigi Rizzo
Date: Monday, December 8, 2008 - 8:44 pm

ok, so here is what I know.

Even though there is no standard, at least ldlinux.sys and perhaps
other bootloaders expect %si to point to a 16-byte record containing
the partition descriptor (same structure as one of the 4 records
at 0x1be in the MBR) for the partition they were loaded from.

ldlinux.sys uses this info to "relocate": it knows the location of the
other sectors of ldlinux.sys relative to the beginning of the partition,
and uses the start-of-partition from the record at %si to compute
these locations in terms of absolute disk positions.

Note that in principle a MBR does not need this info -- even if it
is a multi-sector boot code such as boot0ext, it may well assume to
be located at offset 0.

On the other hand if the code on the MBR uses %si, then you should
set the entry so that at least the starting CHS and LBA info point
to the first sector on disk, i.e. CHS=0,0,1 and LBA=0.

In practical terms -- make %si point to a 16-byte area of memory
containing all 0's except for the byte representing the sector
number for the start of the partition.
See the code in a recent sys/boot/i386/boot0/boot0.S which gives
some details on this.

	cheers
	luigi
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: Maxim Sobolev
Date: Monday, December 8, 2008 - 9:48 pm

I see, thank you for the explanation. It looks like it only makes sense 
for multi-stage boot loaders, when the stage has been loaded from some 
location within the disk and it needs some clue to determine where it 
has came from. In this case we simply emulate BIOS loading MBR, and from 
what I've read here MBR code should make no assumptions with regard to 
%si, so that I would just set it to zero. Do you think it could create 
any issues?

-Maxim
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: John Baldwin
Date: Wednesday, December 10, 2008 - 11:31 am

I don't think this is very useful because CDs are read-only.  You can just as 
easily build a different cdboot rather than having to write some custom 

I don't imagine anyone will know to press a key to get verbose messages, and 
the CD boot process is quick enough you would have to add an artificial delay 

No, because he relocates it, $start is now the relocated address, but the BIOS 

I prefer the existing code to make sure and copy the full boot loader, 
whatever it's size is.

Maxim,

My only comment is to please make the new block comment match the style of the 
existing block comments by having '#\n' lines before and after.

-- 
John Baldwin
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: Jonathan McKeown
Date: Wednesday, December 10, 2008 - 11:37 pm

While you're enhancing cdboot anyway, can I ask how complicated it would be to 
make cdboot serial-console capable? (I'm not a C programmer, I'm a sysadmin - 
but I'd be prepared to try and look at this myself if no-one else is 
interested).

As it stands, the only way I've found to do a serial-console CD-based 
installation is by enabling the serial console in /boot/loader.conf, by which 
time you've already missed several useful points, particularly the entry to 
BIOS settings (if you have a serial-capable BIOS).

Jonathan
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: Giorgos Keramidas
Date: Thursday, December 11, 2008 - 1:45 am

cdboot runs long after the prompt for BIOS setup.  I don't think we can
modify cdboot to add serial console support to systems whose BIOS setup
doesn't support it.

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: Jonathan McKeown
Date: Thursday, December 11, 2008 - 1:52 am

Sorry, of course you're right: I'm talking nonsense.

It's the stage immediately after that that isn't available. I wish I could 
remember why I thought that had caused me a problem once.

Certainly there's a big chunk of the boot process that is accessible through a 
serial console on a disk-based boot that's not available on a serial-console 
boot.
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: Giorgos Keramidas
Date: Thursday, December 11, 2008 - 5:42 am

I'm still not sure what sort of `serial console boot' we are talking
about here.  What's the difference between a `serial console on a
disk-based boot' and a `serial console boot'?
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: Jonathan McKeown
Date: Thursday, December 11, 2008 - 6:09 am

Sorry, there's been an element of ``ready - fire - aim'' about my messages 
today - I'm trying to do several other things at once.

Let me get a serial-boot CD out and play with it - it's a while since I did a 
headless install so I'm working from a vague memory.

I think what I'm saying is that there are several stages in the boot process; 
when booting from a hard drive and using a serial console, all the stages are 
accessible: but when booting from a CD, only the last stage is.

I seem to remember that causing me a problem with a headless machine once upon 
a time (perhaps there was an error at an early stage, with the first hard 
drive failing, and I couldn't see loader(8) to tell it to boot off the second 
drive which was a mirror of the first?).

Certainly I've taken part in a couple of discussions in -questions over the 
last year or two in which people want to know how to make a serial-capable 
install CD - which is not as straightforward as it might be if there were a 
serial-capable cdboot (along the same lines as putting boot0sio instead of 
boot0 on a hard drive).

Jonathan
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
From: Bruce M. Simpson
Date: Thursday, December 11, 2008 - 9:21 am

This sounds and looks cool, diff looks OK (haven't applied), Luigi's 
comments seem well thought out and expressed.

cheers
BMS
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
Previous thread: MAXFILES in subr_param.c by Ivan Voras on Monday, December 8, 2008 - 12:41 pm. (7 messages)

Next thread: Enhancing cdboot [patch for review] by Maxim Sobolev on Monday, December 8, 2008 - 3:40 pm. (1 message)