Setting kern.bootfile, and backup kernels

Garance A Drosihn drosih at rpi.edu
Sun Feb 27 07:45:40 GMT 2005


One thing that surprised me with my last go-round with kernels
is that I didn't seem to have a /boot/kernel.old directory.  At
the time, I didn't have time to investigate further.

I thought I would update my ppc system today, and this time I
checked after doing 'make installkernel', and indeed I again
ended up without a backup kernel.  (luckily I had saved away a
copy before I did the 'installkernel').

It turns out this is because `sysctl -n kern.bootfile' returns
/kernel on the powerpc port, not /boot/kernel/kernel.  You can
also notice this at system startup, because it will say:

Feb 27 01:50:48 mymac syslogd: kernel boot file is /kernel

even though the boot file is not /kernel.  After some quick checks,
it seems the problem is that sys/kern/kern_mib.c has:
       char kernelname[MAXPATHLEN] = "/kernel";

The next question is why does that cause a problem for powerpc when
it doesn't seem to for other platforms?  On most other platforms,
sys/<platform>/<platform>/machdep.c includes some code that looks
interesting.  E.g. from sys/sparc64/sparc64/machdep.c :

	/*
	 * Initialize tunables.
	 */
	init_param2(physmem);
	env = getenv("kernelname");
	if (env != NULL) {
		strlcpy(kernelname, env, sizeof(kernelname));
		freeenv(env);
	}

I *think* that's setting the value we care about, but I might be
wrong on that.  One caveat is that I didn't notice what code
resets the kernelname value for the i386 platform.  I also don't
know who sets up the environment-variable that this code is looking
at when it sets the name.

In any case, it'd be nice if that sysctl variable could be setup
with the right value on powerpc, or people won't have any backup
kernels!

-- 
Garance Alistair Drosehn            =   gad at gilead.netel.rpi.edu
Senior Systems Programmer           or  gad at freebsd.org
Rensselaer Polytechnic Institute    or  drosih at rpi.edu


More information about the freebsd-ppc mailing list