Gentoo Kernel Upgrade Procedure

  • Estimated Time: 10min – 1hour
  • Number Of Commands: 9-10
  • Difficulty: 6
  • Requirements:
    • Computer Running Gentoo
    • Internet
  • Notes: This is based on if you have a current running installation of Gentoo and you are wanting to upgrade your kernel.


Step 1: Syncing Repository & Installing Gentoo Kernel Sources

emerge --sync && eix-update
(Syncs both Emerge and eix command with Gentoo's repository)
emerge =gentoo-sources-5.11.10 --autounmask=y --autounmask-write
(Compile your choose Gentoo sources kernel, replace the version numbers with the desired version)

Step 2: Eselect Desired Kernel Version

eselect kernel list
(List current compiled Gentoo-sources packages for kernel)
eselect kernel set 22
(Input desired kernel number)

Step 3: Genkernel Command, Make Menuconfig And Save Config

genkernel all --kernel-config=default --no-oldconfig --menuconfig
(DO NOT ADD --BTRFS or its running kernel module unless you are running btrfs raid package. This switch was used as an example in the tutorial video. I would recommend adding the LSI drivers if you are in the server environment as they are extremely common. I was surprised to see they were not already enabled by default in Genkernels default menu configuration options, considering they have almost everything else included.)

Now exit out of the kernel configuration menu and save your configuration

Now send a sig term to Genkernel before it finished compiling the kernel. The reason for this is that Genkernel will not compile with the kernel configuration you just made. To do this press Cntrl+C

Step 4: Compile The Kernel And Add Kernel Parameters

genkernel all --kernel-config=/usr/src/linux/kernel.config --no-oldconfig --menuconfig
(This will compile the kernel itself and drop it into your boot partition)
nano /etc/default/grub
(Opens the default grub configuration menu to add your kernel parameters. 
Below is a copy of my default grub configuration file you can use as a reference.)

GRUB_CMDLINE_LINUX="insert kernel parameters here"
#==============READ BELOW INFORMATION=============
#These are kernel parameters that can be added to ' GRUB_CMDLINE_LINUX=" " ' to acheieve specific results
#Note that some of these kernel parameters have been depreciated upon introduction of specific kernel updates or have been changed.

#=====================KVM BASED KERNEL PARAMETERS======================
# isolcpus=8-15 (Isolates CPU from Linux kernel, note: CPU core 0 can only be partial isolated in most kernels)
# nohz_full=8-15 (Sets Isolated cpus to tickless mode, great for KVM latency)
# rcu_nocbs=8-15 (Prevents RCU processing on cores 0-7)
# transparent_hugepage=never (Prevents sharing of hugepages with host)
# iommpu=pt (Important KVM based virtualization setting)
# intel_iommu=on (important setting for KVM based virtualization for Intel CPUs)

#RECOMMENDED PERFORMANCE ENHANCEMENTS FOR ANY SYSTEMS, Don't disable the security patches unless you understand the risks 
# usbcore.autosuspend=-1 (Disables USB power management)
# idle=poll (Prevents CPU from entering idle states)
# intel_idle.max_cstate=0 (Helps maintain Cstates at highest performance level)
# processor.max_cstate=0 (Helps maintain Cstates at highest performance level)
# watchdog=0 (May disable watch dog depending on kernel version)
# nmi_watchdog=0 (Attempts to disable watchdog service)
# force_tsc_stable=1 (Atempts to force mark TSC as stable)
# pcie_aspm=off (Disables PCI bus powermanagement)
# tsc=reliable (Attempts to mark TSC as reliable)
# clock=tsc (Attempts to force TSC clocksource)
# mitigations=off (Disable security patchs for performance gain)
# mds=off (Disable security patch for performance gain)
# nopti (Disable security patch for performance gain)
# spec_store_bypass_disable=off (Disable security patch for performance gain)
# nospectre_v1 (Disable security patch for performance gain)
# nospectre_v2 (Disable security patch for performance gain)
# tsc=nowatchdog (Attempts to disable watchdog for TSC clocksource timer)
# net.ifnames=0 (uses old devices naming scheme for network devices, example eth1 eth2 etc.... RECOMMENED)
# irqaffinity=8-16 (Redirects system interrupts to desired cores)

Step 5: Generate Grub Configuration, Update, Reboot

grub-mkconfig -o /boot/grub/grub.cfg
(Generates the grub configuration with the desired kernel parameters, also make sure you are pointing to the location of your boot partition. I used the default one in this guide.)
emerge --update --deep --keep-going --with-bdeps=y 
(This part is optional, but there is a change that not doing an update down can result in a failed boot, this happens if certain packages are no compatible with the latest kernel you installed.)
(Your done!)