Gentoo kernel upgrade checklist
These steps are partly dependent on my personal Gentoo installation and should not be viewed as a general recipe. Please refer to the official Gentoo wiki on the topic instead. I’m using genkernel to generate an initramfs and GRUB2 as my boot loader.
Before performing a kernel upgrade I would advise to make sure there is enough free space available on the system. I have lost count on the number of failed builds I’ve had due to running out of storage. This has usually been caused by leaving behind older builds under /usr/src/, which takes up a lot of space.
Do not delete anything belonging to your running kernel though, it might still be needed if the new kernel doesn’t work out. Refer to the Gentoo wiki for details on how to free up some needed space. I would suggest having at least 6GB of free disk space on the root partition before building the new kernel.
Preparations
Update the /usr/src/linux symlink to point to the new sources (alternatively use the eselect tool):
ln -sfn /usr/src/linux-4.4.26-gentoo /usr/src/linux
Kernel configuration
Enter the new sources directory and copy the running kernel configuration using zcat. The purpose of this is to build the new kernel using the existing configuration that is already optimized for my hardware. I’m also storing a copy of my running kernel configuration for good measure.
cd /usr/src/linux zcat /proc/config.gz > .config cp .config ~/kernel-config-`uname -r`
The next step is to configure the new kernel. As I’m upgrading from kernel version 4.4.21 to 4.4.26, there are few (if any) new kernel options. I’ll use olddefconfig which applies my old configuration and sets every new option to its default value. If you have better stamina, you’ll review every new kernel option and make well informed choices. I’ll save that for another day.
make olddefconfig
Kernel compilation and install
Compile the new kernel and install the modules. If you’re rebuilding a kernel you probably want to run “make clean” in advance.
make && make modules_install
Install the new kernel with the command:
make install
Create an initramfs
Make sure the boot partition has enough free space. Remove any old and unneeded compressed kernels (vmlinuz) and initramfs’s.
Create a new initial ram file system with Gentoo’s kernel building utility, genkernel:
genkernel --install initramfs
GRUB2
Update the boot loader. Run the grub-mkconfig program to discover the new kernel and generate menu entries.
grub-mkconfig -o /boot/grub/grub.cfg
Boot and enjoy the new kernel.