Note 1: There's no need to merge genkernel if the latest version is already installed.

# 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 [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

# zcat /proc/config.gz > /usr/src/config

Note 2: If you are just making some changes to the same version of kernel and rebuilding it then using the zcat command is probably appropriate. However if you are upgrading or downgrading to a different version of kernel then the zcat command is probably not appropriate. See WARNING No. 1 at the end of this article for what to do in the latter case.

Note 3: If you get an error about an expected integer expression on line 96 of gen_funcs.sh, you will most likely need to update your config files. I used etc-update and selected the second option (-5).

Note 4: If you have an older version of genkernel, for example 3.4.7-x, replace "--lvm" with "--lvm2" and "--splash" with "--gensplash".

Note 5: If you want to be able to use a UUID for real_root in grub.conf then include "--disklabel". Otherwise you can omit the "--disklabel" (which I normally do).

Note 6: "--disklabel" is needed if, after you have built the kernel and reboot, mounting of the root partition fails and you see an error message "blkid: not found". See Gentoo Bugzilla Report No. 229847 for more details. Alternatively, edit grub.conf and make real_root point to the file name of the root partition (/dev/sda5 or whatever) rather than to the root partition's UUID.

Note 7: "--luks" is only needed if you want LUKS support for disk encryption.

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

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:

Most unsupported kernels are in the custom-kernels overlay which is accessible with Layman.

# layman -a custom-kernels

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)? 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. In other words, you would instead use the command:

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:

Note 8: In SL 5.2 and onwards (Layman 1.3.0 and onwards), replace "/usr/local/portage/layman/" with "/var/lib/layman/" in the text above.

Note 9: Use "/usr/portage/distfiles/sabayon-2.6.34-amd64.config" instead of "/var/lib/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.34-amd64.config" (replace "amd64" with "x86" for x86) for kernel 2.6.34 and onwards.

Note 10: The location of the .config file changed again for kernel 3.0.0 (and possibly earlier). Rather than adding notes here ad infinitum, please use the locate command (install mlocate if not already installed) to find the .config file.