Install a new Kernel in Gentoo manually
If emerging world shows you new kernel sources you have to install them — here’s how.
In this Tutorial we’re going through one of my Kernel upgrades step-by-step to give you an understanding of what you have to do for upgrading the Kernel on your machine manually.
If you’re interested in automating those steps please read this: https://medium.com/@dme86/gentoo-automate-your-kernel-upgrades-with-portage-hooks-ddbb59e92958
emerging the world-set will eventually show that there’s a new Kernel available (eg. marked as stable from the gentoo dev’s).
See also: https://packages.gentoo.org/packages/sys-kernel/gentoo-sources
will show you the available kernel sources. The asterisk indicates the chosen sources:
So right now our system is running with the 5.15.16 Kernel and we want to switch our symlink over to 5.15.19 via eselect:
Now change directory to
We have to copy the Kernel configuration from the old Kernel — It can be found in several places:
In my case it looks like this:
We now need to convert the old config so it be used with the new Kernel:
On my system it looked like this:
For new configuration options, the user is asked for a decision. For example:
Anticipatory I/O scheduler (IOSCHED_AS) [Y/n/m/?] (NEW)
The string (NEW) at the end of the line marks this option as new. Left to the string in square brackets are the possible answers: Yes, no, module or ? to show the help. The recommend (i.e. default) answer is capitalized (here Y). The help explains the option or driver.
Unfortunately make oldconfig doesn’t show a lot more information for each option, such as the context, so it is sometimes difficult to give the right answer. In this case the best way to go is to remember the option name and revise it afterwards through one of the graphical kernel configuration tools. For listing new options and doing research about them, make listnewconfig can be used before running make oldconfig.
You can now also have a look at make menuconfig for checking the new options or changing something.
Now we can compile the Kernel via make (this will take some time):
And install modules (if drivers are activated as modules) via
make modules_install
Now install the actual kernel via make install:
Make sure /boot partition is mounted and update your bootloader:
After a reboot our machine now is using the new Kernel:
Awesome!
Make sure everything’s cool before cleaning up Kernel leftovers from the old Kernel.
In this example we also want to keep the sources for the current Kernel because we may need the sources e.g. for updating external kernel modules.
Therefore we add the kernel-sources to our world favorites:
We can now run
to get rid of the old package:
However Portage only removes the files it installed — the files generated during the kernel build and installation remain.
I recommend installing app-admin/eclean-kernel and run it like this:
You now fully switched to a newer Kernel and you’ve cleaned up everything from the old one.
Congratulations!