Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jul 2015 18:28:07 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Lev <leventelist@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: own kernel vs. update
Message-ID:  <20150707182807.bee1587c.freebsd@edvax.de>
In-Reply-To: <20150707180022.02bb01d8@jive.levalinux.org>
References:  <20150707172116.2aa2d38a@jive.levalinux.org> <20150707172902.99e4afc5.freebsd@edvax.de> <20150707180022.02bb01d8@jive.levalinux.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Re-including list, hope that's okay...

On Tue, 7 Jul 2015 18:00:22 +0200, Lev wrote:
> Is there any way to compile my kernel and put the result somewhere else, and
> make the bootloader load my new kernel?

Yes, this is possible. The kernel and the modules can be
found in /usr/obj - the subtree where all parts of the
compiled systems go before they are installed to their
final places. The KODIR variable can be set for the
installation process to _not_ default to /boot/kernel
for the results:

	# cd /usr/src
	# make kernel KERNCONF=MYKERNEL KODIR=mykernel

NB: "make kernel" is shorthand for "make buildkernel &&
make installkernel".

Then you can edit /boot/loader.conf to load your custom
kernel instead of the GENERIC one that's being installed
(and updated with freebsd-update):

	autoboot_delay="5"
	kernel="mykernel"
	bootfile="kernel"

This will make the loader load /boot/mykernel/kernel
and ignore /boot/kernel/kernel (the GENERIC kernel).

See "man loader.conf" and /boot/defaults/loader.conf for
details and examples.

Maybe this is helpful:

https://www.freebsd.org/doc/handbook/kernelconfig-building.html

https://www.freebsd.org/doc/handbook/kernelconfig-trouble.html#kernelconfig-noboot



> And if I want to run the stock
> kernel, I can chose between FreeBSD's and mine?

The loader allows that, too. Its interactive mode can
be used, see the "unload <name>" and "load <name>"
commands when the boot loader has been interrupted.

	unload mykernel
	load kernel
	boot	

This assumes you're not using the boot menu.





-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150707182807.bee1587c.freebsd>