summaryrefslogtreecommitdiff
path: root/content/posts
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-12-16 01:39:24 +0100
committerFederico Angelilli <code@fedang.net>2024-12-16 01:39:24 +0100
commitb41581c1dc6e581863efc6ffebcc487543783fad (patch)
tree7137fa5aaa976b8567136af7ae13adf923043928 /content/posts
parent06bb3e6b18a71f402f87daea5c92c23cea3f9140 (diff)
Update article
Diffstat (limited to 'content/posts')
-rw-r--r--content/posts/gentoo-kernel-upgrade.md93
1 files changed, 64 insertions, 29 deletions
diff --git a/content/posts/gentoo-kernel-upgrade.md b/content/posts/gentoo-kernel-upgrade.md
index 5063e71..7fd3522 100644
--- a/content/posts/gentoo-kernel-upgrade.md
+++ b/content/posts/gentoo-kernel-upgrade.md
@@ -1,10 +1,15 @@
+++
title = "Gentoo kernel upgrade"
summary = "A brief howto on updating the kernel on a Gentoo system."
-categories = [ "linux", "article" ]
+categories = [ "linux", "guide" ]
tags = [ "gentoo", "kernel", "linux", "sysadmin" ]
+++
+In this short guide I summarized the necessary steps to upgrade the
+kernel in a Gentoo system.
+
+We will update from `linux-A.B.C` to `linux-X.Y.Z`.
+
## Preliminary steps
Fetch the sources of the kernel that you want to install.
@@ -12,13 +17,14 @@ Fetch the sources of the kernel that you want to install.
```sh {class="cmd-root"}
emerge -uDUa --with-bdeps=y =sys-kernel/gentoo-sources-X.Y.Z
```
-You may also need to update @world set before updating the kernel.
+You may also need to update `@world` set before updating the kernel.
```sh {class="cmd-root"}
emerge -uDUa --with-bdeps=y @world
```
Using eselect, select the kernel version that you want to upgrade to.
+This will adjust the `/usr/src/linux` symlink.
```sh {class="cmd-root"}
eselect kernel list
@@ -36,22 +42,26 @@ cd /usr/src/linux
Start by copying your `.config` from the old kernel sources.
```sh {class="cmd-root"}
+# from the old folder
cp /usr/src/linux-A.B.C-gentoo/.config /usr/src/linux
+# from the running kernel
+zcat /proc/config.gz > /usr/src/linux/.config
```
-Then, you will have to update the configuration file. The oldconfig command will interactively prompt you to insert values for the new options.
+Then, you will have to update the configuration file.
+The *oldconfig* command will interactively prompt you to insert values for the new options.
```sh {class="cmd-root"}
make oldconfig
```
-Alternatively, the olddefconfig command will automatically insert default values for the new options.
+Alternatively, the *olddefconfig* command will automatically insert default values for the new options.
```sh {class="cmd-root"}
make olddefconfig
```
-To easily change more configuration options you can use the menuconfig command, which will start an interactive ncurses interface.
+To easily change more configuration options you can use the *menuconfig* command, which will start an interactive ncurses interface.
```sh {class="cmd-root"}
make menuconfig
@@ -64,67 +74,91 @@ Manually editing the `.config` file is highly discouraged.
## Building
Once you finished setting your configuration, you can build your kernel with make.
-You can speed up the build process by using multiple make jobs (determine the number with nproc).
+The [NVIDIA drivers](#nvidia-drivers) and [Intel microcode](#intel-microcode) require you
+to do extra steps before building.
+
+You can speed up the build process by using multiple make jobs.
+It is helpful to determine the number of cpu threads with `nproc`.
```sh {class="cmd-root"}
make -jN
```
-## Intel microcode addendum
+## Installation
-Firstly, install the microcode firmware and the tool to manage it.
+First of all, mount the boot partition, if it is not already mounted.
```sh {class="cmd-root"}
-emerge sys-firmware/intel-microcode
+mount /dev/XXX /boot
```
-Use the newly installed `iucode_tool` to get the processor signature and search a microcode bundle with a matching signature.
+Then, you can install the new kernel and modules.
```sh {class="cmd-root"}
-iucode_tool -S
-iucode_tool -S -l /lib/firmware/intel-ucode/*
+make install
+make modules_install
```
-Enable in the kernel configuration the microcode loading features. Then, add in the `Firmware loading facility` the microcode
-bundle found before as a named firmware blob.
-
-After building the kernel, you can easily verify after the boot that the microcode is loaded with dmesg.
+Update your bootloader configuration. If you are using GRUB, you can use grub-mkconfig.
```sh {class="cmd-root"}
-dmesg | grep microcode
+grub-mkconfig -o /boot/grub/grub.cfg
```
-## Installation
+Some kernel modules may be installed by packages and live outside of the kernel source tree (e.g. Nvidia drivers).
+They need to be rebuilt every time you change the kernel.
+Luckily portage provides this handy shorthand.
-First of all, mount the boot partition, if it is not already mounted.
+```sh {class="cmd-root"}
+emerge @module-rebuild
+```
+
+Additionally, some drivers may require firmware updates.
```sh {class="cmd-root"}
-mount /dev/XXX /boot
+emerge sys-kernel/linux-firmware
```
-Then, you can install the new kernel and modules.
+Now you can reboot your machine and everything should hopefully work as intended.
+It is a good habits to keep the old kernel files around (at least until you have verified the new ones).
+
+## Addenda
+
+### Nvidia drivers
+
+I will not delve too much on the details here.
+You can check exactly which kernel options features to enable on the wiki.
```sh {class="cmd-root"}
-make install
-make modules_install
+emerge x11-drivers/nvidia-drivers
```
-Update your bootloader configuration. If you are using GRUB, you can use grub-mkconfig.
+### Intel microcode
+
+Install Intel's `iucode_tool` for managing microcodes.
```sh {class="cmd-root"}
-grub-mkconfig -o /boot/grub/grub.cfg
+emerge sys-firmware/intel-microcode
```
-Some kernel modules may be installed by packages and live outside of the kernel source tree (e.g. Nvidia drivers), and need to be rebuilt.
+Use the tool to get the processor signature and search a microcode bundle with
+a matching signature.
```sh {class="cmd-root"}
-emerge @module-rebuild
+iucode_tool -S
+iucode_tool -S -l /lib/firmware/intel-ucode/*
```
-Additionally, updating the firmware may be required by some drivers.
+Enable in the kernel configuration the microcode loading features and add in
+the *Firmware loading facility* the microcode bundle found before as a named
+firmware blob, then build the kernel.
+
+Now build and install the kernel.
+
+Verify after the rebooting that the microcode is loaded by the kernel.
```sh {class="cmd-root"}
-emerge sys-kernel/linux-firmware
+dmesg | grep microcode
```
## References
@@ -132,3 +166,4 @@ emerge sys-kernel/linux-firmware
- https://wiki.gentoo.org/wiki/Kernel/Upgrade
- https://wiki.gentoo.org/wiki/Kernel/Removal
- https://wiki.gentoo.org/wiki/Intel_microcode
+- https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers