How to switch between installed kernel and developed kernel

Bjørn Mork bjorn at mork.no
Mon Mar 22 08:59:15 EDT 2021


Gidi Gal <gidi.gal.linux at gmail.com> writes:

> I am new to kernel development, currently working on
> https://kernelnewbies.org/FirstKernelPatch. I reached the step "Install
> your changes" in "Modifying a driver on native Linux". I would like to
> separate my developed kernel and my installed kernel and to switch between
> the two in order to test my changes. I am not sure that my tutorial
> explains how to do that. If you have a link that proposes a workflow for
> this request (or if my tutorial does explain this workflow and I'm missing
> the exact paragraph that does that) please let me know.

The answer depends on your choice of bootloader, distro etc.

But one way to do this is to build a native kernel package for your
distro and simply install that like any other package. So instead of

 make -j2; sudo make modules_install install

you'll do somethong like (or maybe give a more explicit version than '*')

 make -j2 bindeb-pkg; sudo dpkg -i ../linux-image-*.deb

or similare with "binrpm-pkg" for the RPM based distros.

With this you'll end up with your testing kernel as an additional choice
in the bootloader menu, keeping all your previously installed kernels as
alternatives.

Note that this way of testing is quite slow since you'll rebuild
everythng and reboot a bare metal machine.  There are easier ways to
test many kernel changes, like rebuilding only one module and load it in
your running kernel. And there is of course always a very real risk of
crashing, and possibly thrashing too...  So if you can, you might want
to run test your kernels on a virtual machine, or some other test
machine, instead of your development machine.


Bjørn



More information about the Kernelnewbies mailing list