Subject: Re: which kernel booted?
To: None <>
From: David Laight <>
List: tech-kern
Date: 01/04/2002 15:26:47
After my grovelling through the x86 bootstrap code before xmas I found
that it is almost impossible for the kernel to be passed the device
that the kernel was loaded from.

Amongst the problems is that somewhere you have to switch from BIOS
disk numbers to the major/minor number and device driver.  There is no
reason to suppose that the OS and BIOS find the same set of disk channels
or map them in the same order.

There are also issues with detecting the correct (or same?) disk partition/
slice at all stages of the boot process.

Additionally, knowing the name of the kernel isn't enough.  You want to
find the same file - eg after a new kernel is copied to /netbsd you don't
want to access it.

Maybe passing the basename of the file and (say) its size and last-modified
time.  This is probably enough to verify the correct file - without the
expense of an MD5 checksum.

Maybe someone should consider nameing disks, and identifying them that
way - rather than by physical position in the system.

> > In some email I received from matthew green, sie wrote:
> > [...]
> > > sometimes the kernel image isn't available to the NetBSD userland
> > > at all.  eg, a shark netbooted kernel doens't have to exist in
> > > the machine's / at all.  i might have loaded my kernel over the
> > > ethernet and then used a local root filesystem...  so while you can
> > > add to the times when this _is_ available, you can never make it
> > > always possible.
> >
> > Netbooting always seems to be the "forgotten child".
> >
> > The problem here is that it _may_ be the same or it _may not_, with no
> > rule of thumb either way.  The safest thing might be to err on the side
> > of caution and just have netbooting pass the kernel a null kernel name
> > rather than what it's loaded
> Or pass the kernel name as a URI. If it's a file, "file:/file/path" says
> where it is. If it's tftp'd, "tftp://host/file".
> To the extent our boot methods match standard URI types (file:, ftp:,
> etc.) we should use the standard format. For other formats, we should make
> up URI formats (like macosfile: for mac68k where the kernel is loaded off
> of a MacOS file system).
> Take care,
> Bill