HOWTO: Upgrade kernel using genkernel
Open a Konsole/Terminal window and use the su command to log in as the root user (and enter the root password):
$ su root
# equo install git # equo i layman # layman -L # layman -a sabayon-distro
If you have a separate boot partition, make sure it is mounted onto /boot before proceeding. For example, if the boot partition is /dev/sda3 then:
# mount /dev/sda3 /boot
Update portage and genkernel first, then install the newest kernel source code:
# emerge --sync && layman -S
# emerge -av genkernel
Check your current kernel version:
# uname -r 4.11.0-sabayon
# USE="sources_standalone" emerge sabayon-sources
... * This package will overwrite one or more files that may belong to other * packages (see list below). You can use a command such as `portageq * owners / <filename>` to identify the installed package that owns a * file. If portageq reports that only one package owns a file then do * NOT file a bug report. A bug report is only useful if it identifies at * least two or more packages that are known to install the same file(s). * If a collision occurs and you can not explain where the file came from * then you should simply ignore the collision since there is not enough * information to determine if a real problem exists. Please do NOT file * a bug report at https://bugs.gentoo.org/ unless you report exactly * which two packages install the same file(s). See * https://wiki.gentoo.org/wiki/Knowledge_Base:Blockers for tips on how * to solve the problem. And once again, please do NOT file a bug report * unless you have completely understood the above message. * * Detected file collision(s): * * /usr/src/linux-4.11.0-sabayon/.config * /usr/src/linux-4.11.0-sabayon/Makefile * * Searching all installed packages for file collisions... * * Press Ctrl-C to Stop * * sys-kernel/linux-sabayon-4.11.3-r1:4.11::sabayon-distro * /usr/src/linux-4.11.0-sabayon/.config * /usr/src/linux-4.11.0-sabayon/Makefile * * Package 'sys-kernel/sabayon-sources-4.11.4' NOT merged due to file * collisions. If necessary, refer to your elog messages for the whole * content of the above message. >>> Failed to install sys-kernel/sabayon-sources-4.11.4, Log file: >>> '/var/tmp/portage/sys-kernel/sabayon-sources-4.11.4/temp/build.log'
You can resolve this conflict with -collision-protect:
FEATURES="-collision-protect" USE="sources_standalone" emerge sabayon-sources
Configure /usr/src/linux symlink:
# eselect kernel list
Note which kernel in the list you want to install. It has a number like this next to it: [x]. More than likely x = 2 . Now use this number in the following command, in order to set the symlink to the new version of the kernel:
# eselect kernel set x
You can check symlink value with commands file /usr/src/linux or readlink /usr/src/linux
WARNING No. 1: Think carefully about what you are trying to achieve here, i.e. do you want to upgrade to a newer version of the kernel or do you want to rebuild the same version of the kernel you are currently using (perhaps, optionally, making some manual changes to the kernel configuration)?
For other unsupported kernels, please have a look at the unsupported software section at the Gentoo forums.
Most unsupported kernels are in the custom-kernels overlay which is accessible with Layman.
# layman -a custom-kernels
Edit genkernel configuration file
"The actual behavior of genkernel depends on a large variety of options, the majority of which can be set/unset in the /etc/genkernel.conf file" (see genkernel page, and do actually read comments in the /etc/genkernel.conf file itself)
Prepare kernel sources configuration file
# zcat /proc/config.gz > /usr/src/config
see below, why not /usr/src/linux/.config, also read output of ls -1 /etc/kernels/
Note that the zcat command mentioned above creates a configuration file based on the currently-running kernel. However, the configuration of the current kernel may not be suitable for the new version of the kernel sources you just merged (downloaded). It could be that you want or need to use a configuration file for the new version of kernel you have just merged. To give a hypothetical example in order to try and illustrate the distinction, let's suppose you are currently running the 2.6.22 kernel but now want to build the 2.6.25 kernel. In which case you would not need to bother with the zcat command as some of the configuration parameters in the 2.6.22 kernel do not exist in the 2.6.25 kernel (and vice versa), so instead of using a file /usr/src/config you could create using zcat, you would instead use the .config file (notice the dot) in the directory /usr/src/linux-2.6.25-sabayon/ created when you merged linux-sabayon-2.6.25 earlier, which is different from the .config file (and config file created by zcat) for the 2.6.22 kernel.
Notice the difference between "--kernel-config=/usr/src/config" ( the file "config" would be created by using the zcat command) and "--kernel-config=/usr/src/linux-2.6.25-sabayon/.config" (the file ".config" would be created when you merge linux-sabayon-2.6.25).
Note also that the file /usr/src/linux-2.6.25-sabayon/.config would be the same as the file /usr/portage/local/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.25-x86.config if you merged linux-sabayon-2.6.25 for the x86 edition of Sabayon Linux, or the file /usr/portage/local/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.25-amd64.config if you merged linux-sabayon-2.6.25 for the x86_64 edition of Sabayon Linux. Thus, if you run one of the above commands and an error message is displayed to the effect that /usr/src/linux-2.6.25-sabayon/.config cannot be opened, then try using --kernel-config=/usr/portage/local/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.25-x86.config (or /usr/portage/local/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.25-amd64.config if you have the 64-bit edition of SL installed). Note also that the default location of the Portage overlay sources has been changed from directory /usr/portage/local/layman/ to directory /usr/local/portage/layman/ in the latest version of SL (and Gentoo), so modify the aforementioned command accordingly if you are using SL 4.0 and onwards. For example, in the case of the 2.6.31 kernel the switch would be the following for the x86 edition:
and the following for the x86_64 edition:
Do the following if you manually edited your partitions:
# genkernel --kernel-config=/usr/src/config --menuconfig --splash=sabayon --disklabel --luks all
Do the following if you used anaconda's automatic diskdruid or created a lvm:
# genkernel --kernel-config=/usr/src/config --menuconfig --splash=sabayon --disklabel --lvm --luks all
Build kernel and modules
Launch genkernel script:
# genkernel --kernel-config=/usr/src/linux-2.6.25-sabayon/.config --menuconfig --bootloader=grub --splash=sabayon --disklabel all
# genkernel --kernel-config=/usr/src/linux-2.6.25-sabayon/.config --menuconfig --bootloader=grub --splash=sabayon --disklabel --lvm all
if you used anaconda's automatic diskdruid or created a lvm.)
When you get into the linux kernel menu where you can go and edit all sorts of linux kernel variables (and it's very tempting to mess with), unless you are very, VERY well versed in understanding what it is you are doing, the default settings are good and reliable to start with and will create a kernel that actually WORKS.
SO, you can simply exit and save without changing anything, this way your kernel will compile and you can actually boot into it.
Then we need to rebuild our modules and such to make sure everything works with the new kernel. So do:
# module-rebuild rebuild
Rebuild other drivers if necessary
Sometimes this will fail if old modules are still around, so you might need to re-emerge your video drivers
I had to re-emerge my nvidia drivers because the old drivers were no longer in the portage tree:
# emerge nvidia-drivers
OR, if you have an ATI GPU:
# emerge ati-drivers
and if it says that ati-drivers-<version> is unavailable, try:
# module-rebuild del ati-drivers-<version>
If you still have problems, you can clean-out and renew your moduledb first like this:
# rm /var/lib/module-rebuild/moduledb # module-rebuild populate # module-rebuild rebuild
Note that the latest kernel has built-in wireless stuff, causing the wireless modules to fail the module-rebuild. The trick is to make sure the wireless stuff is enabled during the kernel compile.
Currently genkernel only knows about Grub Legacy, so you will need to regenerate the Grub2 grub.cfg file after completing the above, using the following command:
# grub2-mkconfig -o /boot/grub/grub.cfg
Any questions/problems/comments can be posted on the forums.
Choose to boot into your freshly compiled kernel, the old reliable one will still be there and may be a nice backup for safe keeping so, don't worry about getting rid of it.
Test boot with qemu (optionally)
# qemu-system-x86_64 -enable-kvm -drive file=/dev/sda,if=virtio,readonly,index=0,cache=none
(change /dev/sda to your actual drive name)