<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Just another blog (Posts about gentoo)</title><link>https://www.setphaserstostun.org/</link><description></description><atom:link href="https://www.setphaserstostun.org/categories/gentoo.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2026 &lt;a href="mailto:gabriele.svelto@gmail.com"&gt;Gabriele Svelto&lt;/a&gt; </copyright><lastBuildDate>Tue, 04 Aug 2026 22:12:35 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Secure Boot on Gentoo with shim &amp; GRUB</title><link>https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/</link><dc:creator>Gabriele Svelto</dc:creator><description>&lt;p&gt;Getting Secure Boot to work on Gentoo has traditionally been tricky, due to the
widespread use of custom kernels and the absence of pre-signed boot loaders
like those used by the mainstream binary Linux distributions. Since the
required information is spread through the handbook and the wiki I decided to
write one easy-to-follow tutorial instead, in order to make this information a
bit more accessible.&lt;/p&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;This guide has been updated in August 2026 and the procedure presented here
is slightly different than the original one. In particular the old version
relied on manually creating and signing a GRUB standalone EFI executable
that contained both the GRUB modules and configuration file. This version
relies instead on the standalone signed GRUB EFI executable that is
automatically generated when building the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/grub&lt;/span&gt;&lt;/code&gt; package and
read on an external configuration file. This is more convenient for users as
the bootloader does not need to be regenerated when only the configuration
file changes.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;There are several ways to make Secure Boot work, the goal being that every
executable loaded by the system during boot is signed and can be verified by
the one loading it. The method I've chosen uses the &lt;a class="reference external" href="https://github.com/rhboot/shim/"&gt;shim bootloader&lt;/a&gt; to
launch a standalone installation of &lt;a class="reference external" href="https://www.gnu.org/software/grub/"&gt;GRUB&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The way the boot chain will work is the following:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Your machine's UEFI firmware will load the &lt;strong&gt;shim&lt;/strong&gt; bootloader, verifying its
signature using the pre-loaded Microsoft-provided key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;shim&lt;/strong&gt; bootloader will load a GRUB standalone executable which contains
all the modules GRUB needs to run. This executable will be signed with a key
we'll generate and load into the Machine Key Owner list, a user-managed list
of keys. The &lt;strong&gt;shim&lt;/strong&gt; bootloader will also set GRUB's &lt;strong&gt;shim_lock&lt;/strong&gt; option
which will inform GRUB to verify all the files it loads.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The GRUB standalone executable will thus launch a signed Linux kernel. This
will either be a Gentoo binary distribution kernel - in which case we'll also
load Gentoo binary distribution key in the MOK to verify it - or a custom
kernel which will be signed with the same key we'll have used to sign GRUB.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Linux kernel will optionally enforce that the modules it loads are also
signed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In a dual-boot system GRUB will also be able to chain-load the Microsoft
Windows bootloader or other signed UEFI executables, never breaking the
Secure Boot chain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that you can follow this procedure in place of following the &lt;strong&gt;Configuring
the bootloader&lt;/strong&gt; chapter of the Gentoo handbook, or do it on an already
existing installation. You don't need to turn off Secure Boot for the procedure
to work. In fact, if you're installing Gentoo using a live distribution that
supports Secure Boot, you can do the entire installation without ever turning
it off.&lt;/p&gt;
&lt;nav class="contents" id="contents" role="doc-toc"&gt;
&lt;p class="topic-title"&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#top"&gt;Contents&lt;/a&gt;&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#preparing-the-system" id="toc-entry-1"&gt;Preparing the system&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#setting-up-the-signing-keys" id="toc-entry-2"&gt;Setting up the signing keys&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#configuring-and-installing-the-required-packages" id="toc-entry-3"&gt;Configuring and installing the required packages&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#installing-the-kernel" id="toc-entry-4"&gt;Installing the kernel&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#gentoo-binary-distribution-kernel" id="toc-entry-5"&gt;Gentoo binary distribution kernel&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#gentoo-kernel-built-from-sources" id="toc-entry-6"&gt;Gentoo kernel built from sources&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#custom-kernel" id="toc-entry-7"&gt;Custom kernel&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#installing-the-shim-and-grub-bootloaders" id="toc-entry-8"&gt;Installing the shim and GRUB bootloaders&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#importing-the-key-in-the-mok-list" id="toc-entry-9"&gt;Importing the key in the MOK list&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#creating-a-new-efi-boot-entry" id="toc-entry-10"&gt;Creating a new EFI boot entry&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#reboot-enrolling-the-key-in-the-mok-list" id="toc-entry-11"&gt;Reboot &amp;amp; enrolling the key in the MOK list&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#conclusion" id="toc-entry-12"&gt;Conclusion&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#updating-and-troubleshooting" id="toc-entry-13"&gt;Updating and troubleshooting&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#kernel-updates" id="toc-entry-14"&gt;Kernel updates&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#grub-updates" id="toc-entry-15"&gt;GRUB updates&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#shim-bootloader-updates-troubleshooting" id="toc-entry-16"&gt;shim bootloader updates &amp;amp; troubleshooting&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#windows-dual-boot-troubleshooting" id="toc-entry-17"&gt;Windows dual-boot troubleshooting&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#motherboard-uefi-firmware-updates-troubleshooting" id="toc-entry-18"&gt;motherboard UEFI firmware updates &amp;amp; troubleshooting&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/nav&gt;
&lt;section id="preparing-the-system"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-1" role="doc-backlink"&gt;Preparing the system&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;First of all we need to mount the EFI boot partition. This is a FAT-formatted
partition that you'll have made during the partitioning step of a Gentoo
installation, or was already present if you're installing Gentoo alongside
Windows or another Linux distribution using UEFI boot. This guide assumes that
this partition will be mounted under the &lt;code class="docutils literal"&gt;/boot/efi&lt;/code&gt; mount-point, so you'll
have something like this in &lt;code class="docutils literal"&gt;/etc/fstab&lt;/code&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;/dev/sda1       /boot/efi       vfat            defaults            0 0&lt;/pre&gt;
&lt;p&gt;Go on and mount the partition if it hasn't been mounted already:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mount /boot/efi&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="setting-up-the-signing-keys"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-2" role="doc-backlink"&gt;Setting up the signing keys&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It's now time to generate the keys that we'll use to sign GRUB. We'll generate
an RSA-2048 certificate in &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail"&gt;PEM&lt;/a&gt; format which will be used to sign GRUB
(as well as the kernel and its modules if you're building it from source):&lt;/p&gt;
&lt;pre class="literal-block"&gt;# openssl req -new -nodes -utf8 -sha256 -x509 -outform PEM \
    -out /root/secureboot/MOK.pem -keyout /root/secureboot/MOK.pem \
    -subj "/CN=&amp;lt;your name here&amp;gt;/"&lt;/pre&gt;
&lt;p&gt;Note that it is good practice to keep this certificate offline, but for
simplicity this guide assumes that it is under &lt;code class="docutils literal"&gt;/root/secureboot/&lt;/code&gt;. You can
always move it to a removable drive later.&lt;/p&gt;
&lt;p&gt;Now we also need the certificate in binary &lt;a class="reference external" href="https://en.wikipedia.org/wiki/X.690#DER_encoding"&gt;DER&lt;/a&gt; format. This version of the
certificate will be loaded into the MOK list.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# openssl x509 -in /root/secureboot/MOK.pem -outform DER -out /root/secureboot/MOK.cer&lt;/pre&gt;
&lt;p&gt;Now modify your &lt;code class="docutils literal"&gt;make.conf&lt;/code&gt; so that the &lt;code class="docutils literal"&gt;secureboot&lt;/code&gt; USE flag is enabled
and the &lt;cite&gt;SECUREBOOT_SIGN_KEY&lt;/cite&gt;, &lt;cite&gt;SECUREBOOT_SIGN_CERT&lt;/cite&gt;, &lt;cite&gt;MODULES_SIGN_KEY&lt;/cite&gt;
and &lt;cite&gt;MODULES_SIGN_CERT&lt;/cite&gt; variables point to the certificate in the PEM format.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# USE flags
USE=".. secureboot .."

# Secure Boot signing keys
SECUREBOOT_SIGN_KEY="/root/secureboot/MOK.pem"
SECUREBOOT_SIGN_CERT="/root/secureboot/MOK.pem"
MODULES_SIGN_KEY="/root/secureboot/MOK.pem"
MODULES_SIGN_CERT="/root/secureboot/MOK.pem"&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="configuring-and-installing-the-required-packages"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-3" role="doc-backlink"&gt;Configuring and installing the required packages&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now let's install the packages we'll use: we need the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/efibootmgr&lt;/span&gt;&lt;/code&gt;
package to add new boot entries, the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/mokutil&lt;/span&gt;&lt;/code&gt; package to load our
keys into the &lt;cite&gt;Machine Owner Key list&lt;/cite&gt; and the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/shim&lt;/span&gt;&lt;/code&gt; package that
contains the signed &lt;strong&gt;shim&lt;/strong&gt; bootloader.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# echo emerge --ask sys-boot/efibootmgr sys-boot/mokutil sys-boot/shim&lt;/pre&gt;
&lt;p&gt;I also recommend rebuilding the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-apps/kmod&lt;/span&gt;&lt;/code&gt; package with the &lt;code class="docutils literal"&gt;pkcs7&lt;/code&gt;
USE flag, so that the &lt;strong&gt;modinfo&lt;/strong&gt; command will show you the signatures in
the kernel modules.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# echo "sys-apps/kmod pkcs7" &amp;gt;&amp;gt; /etc/portage/package.use
# emerge --ask --newuse --oneshot sys-apps/kmod&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="installing-the-kernel"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-4" role="doc-backlink"&gt;Installing the kernel&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now that the keys have been set up it's time to make sure that the kernel image
is signed so that it can be verified by GRUB when loading it. The procedure is
different depending on the type of kernel you're using.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;If you're using Gentoo's binary distribution kernel (via the
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-kernel-bin&lt;/span&gt;&lt;/code&gt; package) refer to the
&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#gentoo-binary-distribution-kernel"&gt;Gentoo binary distribution kernel&lt;/a&gt; instructions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you're using a custom kernel built using the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-kernel&lt;/span&gt;&lt;/code&gt;
package use the &lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#gentoo-kernel-built-from-sources"&gt;Gentoo kernel built from sources&lt;/a&gt; instructions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally if you're using a custom kernel built by hand
(&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-sources&lt;/span&gt;&lt;/code&gt;, &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/vanilla-sources&lt;/span&gt;&lt;/code&gt; or anything
else that's completely built from source) use the &lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#custom-kernel"&gt;Custom kernel&lt;/a&gt;
instructions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;section id="gentoo-binary-distribution-kernel"&gt;
&lt;h3&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-5" role="doc-backlink"&gt;Gentoo binary distribution kernel&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Gentoo binary distribution kernels are already signed with Gentoo's binary
distribution key. The public key, which we'll need to verify the signature,
is installed alongside the kernel. So proceed to install it as usual:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# emerge --ask sys-kernel/gentoo-kernel-bin&lt;/pre&gt;
&lt;p&gt;Now we need to import the key in the MOK list. The key is stored under
&lt;code class="docutils literal"&gt;certs/signing_key.x509&lt;/code&gt; in the kernel sources installation directory. To
load it into the MOK list use the following command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mokutil --import /usr/src/linux-&amp;lt;version&amp;gt;-gentoo-dist/certs/signing_key.x509&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;mokutil&lt;/strong&gt; will ask for a password to enroll the key. This will be used only
once after you have rebooted the system during the enrollment process, it can
be discarded afterwards.&lt;/p&gt;
&lt;p&gt;If &lt;strong&gt;mokutil&lt;/strong&gt; complains about the key already being in the keyring you can
force it to be loaded like this (this might happen if a firmware update wiped
the MOK list and you need to re-enroll the key).&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mokutil --ignore-keyring --import /usr/src/linux-&amp;lt;version&amp;gt;-gentoo-dist/certs/signing_key.x509&lt;/pre&gt;
&lt;p&gt;That's it, you can now move on to the
&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#installing-the-shim-and-grub-bootloaders"&gt;Installing the shim and GRUB bootloaders&lt;/a&gt; section.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="gentoo-kernel-built-from-sources"&gt;
&lt;h3&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-6" role="doc-backlink"&gt;Gentoo kernel built from sources&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When building the kernel using the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-kernel&lt;/span&gt;&lt;/code&gt; package the
kernel will be automatically signed with the keys that we've set up in the
&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#setting-up-the-signing-keys"&gt;Setting up the signing keys&lt;/a&gt; section. To sign the loadable modules too set
the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;modules-sign&lt;/span&gt;&lt;/code&gt; USE flag in &lt;code class="docutils literal"&gt;make.conf&lt;/code&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;USE=".. modules-sign .."&lt;/pre&gt;
&lt;p&gt;This will instruct the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-kernel&lt;/span&gt;&lt;/code&gt; package to also sign all the
modules using the aforementioned keys. Additionally, all packages that build
third-party modules will automatically sign them.&lt;/p&gt;
&lt;p&gt;Now install the kernel as usual:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# emerge --ask sys-kernel/gentoo-kernel&lt;/pre&gt;
&lt;p&gt;That's it, you can now move on to the
&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#installing-the-shim-and-grub-bootloaders"&gt;Installing the shim and GRUB bootloaders&lt;/a&gt; section.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="custom-kernel"&gt;
&lt;h3&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-7" role="doc-backlink"&gt;Custom kernel&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When building your own kernel you'll need to specify the module signing key in
your .config file and force signature checks on all loaded modules:&lt;/p&gt;
&lt;pre class="literal-block"&gt;CONFIG_MODULE_SIG_FORCE=y
CONFIG_MODULE_SIG_KEY="/root/secureboot/MOK.pem"&lt;/pre&gt;
&lt;p&gt;Now build and install the kernel as usual&lt;/p&gt;
&lt;pre class="literal-block"&gt;# make
# make install
# make modules_install&lt;/pre&gt;
&lt;p&gt;The modules will be signed automatically but the kernel image needs to be signed
manually:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# sbsign --key /root/secureboot/MOK.key --cert /root/secureboot/MOK.crt /boot/vmlinuz-&amp;lt;version&amp;gt;&lt;/pre&gt;
&lt;p&gt;That's it, you can now move on to the
&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#installing-the-shim-and-grub-bootloaders"&gt;Installing the shim and GRUB bootloaders&lt;/a&gt; section.&lt;/p&gt;
&lt;/section&gt;
&lt;/section&gt;
&lt;section id="installing-the-shim-and-grub-bootloaders"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-8" role="doc-backlink"&gt;Installing the shim and GRUB bootloaders&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now let's add a folder for our bootloader to the EFI partition and move the
&lt;strong&gt;shim&lt;/strong&gt; bootloader inside of it.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mkdir --parents /boot/efi/EFI/gentoo
# cp /usr/share/shim/mmx64.efi /boot/efi/EFI/gentoo/
# cp /usr/share/shim/BOOTX64.EFI /boot/efi/EFI/gentoo/&lt;/pre&gt;
&lt;p&gt;Notice how the &lt;strong&gt;shim&lt;/strong&gt; bootloader is made up of two executables: the actual
bootloader &lt;code class="docutils literal"&gt;BOOTX64.EFI&lt;/code&gt; and a tool to manipulate the MOK list
(&lt;code class="docutils literal"&gt;mmx64.efi&lt;/code&gt;). The latter will be used during the first reboot to enroll our
keys.&lt;/p&gt;
&lt;p&gt;The next step is to install GRUB. Make sure that you've got UEFI support
enabled by setting the &lt;cite&gt;GRUB_PLATFORMS&lt;/cite&gt; variable in &lt;code class="docutils literal"&gt;make.conf&lt;/code&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;GRUB_PLATFORMS="efi-64"&lt;/pre&gt;
&lt;p&gt;If you want to dual-boot Windows - or other Linux distributions - enable the
&lt;cite&gt;mount&lt;/cite&gt; USE flag so that GRUB's OS prober will be able to find them.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# echo "sys-boot/grub mount" &amp;gt;&amp;gt; /etc/portage/package.use&lt;/pre&gt;
&lt;p&gt;Now install the GRUB package:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# emerge --ask sys-boot/grub&lt;/pre&gt;
&lt;p&gt;Installing the package is enough to generate the signed GRUB EFI executable. So
let's install it alongside the shim bootloader in the EFI partition.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# cp /usr/lib/grub/grub-x86_64.efi.signed /boot/efi/EFI/gentoo/grubx64.efi&lt;/pre&gt;
&lt;p&gt;Note that we've placed the signed GRUB bootloader next to the shim bootloader.
It needs to be called &lt;strong&gt;grubx64.efi&lt;/strong&gt; because that's what the &lt;strong&gt;shim&lt;/strong&gt;
bootloader expects to find.&lt;/p&gt;
&lt;p&gt;Now adjust the &lt;code class="docutils literal"&gt;/etc/default/grub&lt;/code&gt; configuration file with the options suitable
for your machine. In case you want to dual-boot Windows you'll need to
explicitly set the &lt;cite&gt;GRUB_DISABLE_OS_PROBER&lt;/cite&gt; option:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# Enable OS prober
GRUB_DISABLE_OS_PROBER=false&lt;/pre&gt;
&lt;p&gt;We can now generate GRUB's configuration which will sit alongside the
bootloader EFI executable, so it's worth mentioning why the bootloader
executable itself already contains all the modules and we don't need to install
them with the &lt;strong&gt;grub-install&lt;/strong&gt; tool.  By default GRUB's configuration will use
the &lt;strong&gt;shim_lock&lt;/strong&gt; verifier. This is a mechanism that causes the &lt;strong&gt;shim&lt;/strong&gt;
bootloader to inform GRUB that it's being loaded in a Secure Boot environment
and thus it's now GRUB's turn to validate the boot chain. When this happens
GRUB will verify all the executable files it loads - including its modules. A
traditional GRUB installation will store all these files separately and require
a separate GPG signature for &lt;em&gt;each of them&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Adding and maintaining these signatures is an unwieldy and error-prone
exercise and requires a separate GPG key in addition to the ones we've already
generated. A standalone installation on the other hand produces a single
executable which contains a memdisk holding all the modules and potentially
fonts, themes as well as the configuration. This executable needs to be signed
only once - which happens when we install or update the package - greatly
reducing the maintenance burden.&lt;/p&gt;
&lt;p&gt;With that said let's proceed. We'll generate GRUB's configuration using
&lt;strong&gt;grub-mkconfig&lt;/strong&gt; then modify the environment so that it will be regenerated
correctly when need be:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# grub-mkconfig -o /boot/efi/EFI/gentoo/grub.cfg&lt;/pre&gt;
&lt;p&gt;Finally let's add the path to this configuration to the environment. This way
whenever you'll install a new kernel GRUB's configuration file will be
automatically regenerated by the &lt;strong&gt;installkernel&lt;/strong&gt; package.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# echo 'GRUB_CFG="/boot/efi/EFI/gentoo/grub.cfg"' &amp;gt; /etc/env.d/99grub
# env-update&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="importing-the-key-in-the-mok-list"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-9" role="doc-backlink"&gt;Importing the key in the MOK list&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It's now time to import the key we've used to sign GRUB (and possibly the
kernel too) into the MOK list. This is a two step process, the first part is
to import the key:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mokutil --import /root/secureboot/MOK.cer&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;mokutil&lt;/strong&gt; will ask for a password to enroll the key. This will be used only
once after you have rebooted the system during the enrollment process, it can
be discarded afterwards.&lt;/p&gt;
&lt;p&gt;If &lt;strong&gt;mokutil&lt;/strong&gt; complains about the key already being in the keyring you can
force it to be loaded like this (this might happen if a firmware update wiped
the MOK list and you need to re-enroll the key).&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mokutil --ignore-keyring --import /root/secureboot/MOK.cer&lt;/pre&gt;
&lt;p&gt;The second part will happen upon the next reboot. Remember the &lt;code class="docutils literal"&gt;mmx64.efi&lt;/code&gt;
file we've put in the EFI partition alongside the &lt;strong&gt;shim&lt;/strong&gt; bootloader? Upon
being loaded, &lt;strong&gt;shim&lt;/strong&gt; will notice that we're trying to import a key in the MOK
and launch it to do the actual enrollment.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="creating-a-new-efi-boot-entry"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-10" role="doc-backlink"&gt;Creating a new EFI boot entry&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The last step is to create a new EFI boot entry for the &lt;strong&gt;shim&lt;/strong&gt; bootloader.
Note that we don't need an entry for GRUB, because it will be loaded via SHIM.&lt;/p&gt;
&lt;p&gt;The boot entry can be created with this command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# efibootmgr --disk &amp;lt;disk_with_efi_partition&amp;gt; --part &amp;lt;partition_number&amp;gt; --create -L "shim" -l '\EFI\gentoo\BOOTX64.EFI'&lt;/pre&gt;
&lt;p&gt;&lt;cite&gt;disk_with_efi_partition&lt;/cite&gt; is the disk which holds the EFI partition, and
&lt;cite&gt;partition_number&lt;/cite&gt; is the number of the EFI partition in the GPT table. So,
if your EFI partition is on the &lt;code class="docutils literal"&gt;/dev/sda1&lt;/code&gt; device you'll create the boot
entry with:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# efibootmgr --disk /dev/sda --part 1 --create -L "shim" -l '\EFI\gentoo\BOOTX64.EFI'&lt;/pre&gt;
&lt;p&gt;This command should also set the new boot entry as the default one,
double-check it with:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# efibootmgr
BootCurrent: 0003
Timeout: 0 seconds
BootOrder: 0003,0000,0017,0018,0019,001A,001B,001C,001D,001E,001F,0024,0002
...
Boot0003* shim  HD(1,GPT,e8389b70-d497-40e7-94a5-0b4a48732aa0,0x800,0x82000)/File(\EFI\gentoo\BOOTX64.EFI)
...&lt;/pre&gt;
&lt;p&gt;Notice how the &lt;cite&gt;BootOrder&lt;/cite&gt; variable starts with &lt;cite&gt;0003&lt;/cite&gt; which corresponds to the
&lt;cite&gt;shim&lt;/cite&gt; entry in this example. If this is not the case adjust the boot order
using:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# efibootmgr --bootorder &amp;lt;shim_entry&amp;gt;,&amp;lt;other_entry&amp;gt;,...&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="reboot-enrolling-the-key-in-the-mok-list"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-11" role="doc-backlink"&gt;Reboot &amp;amp; enrolling the key in the MOK list&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can now reboot your machine. Upon the next reboot the &lt;strong&gt;shim&lt;/strong&gt; bootloader
will notice that you tried to enroll a new key and load the
&lt;cite&gt;Shim UEFI key management executable&lt;/cite&gt;. It will look like this (I apologize for
the horrible Moiré artifacts on the pictures):&lt;/p&gt;
&lt;img alt="/images/secure_boot_1.jpg" class="align-center" src="https://www.setphaserstostun.org/images/secure_boot_1.jpg"&gt;
&lt;p&gt;After pressing a key you'll be presented with the key management menu, choose
the &lt;cite&gt;Enroll MOK&lt;/cite&gt; entry:&lt;/p&gt;
&lt;img alt="/images/secure_boot_2.jpg" class="align-center" src="https://www.setphaserstostun.org/images/secure_boot_2.jpg"&gt;
&lt;p&gt;You will presented with the list of keys you enrolled. One if you only added
yours or two if you also added the Gentoo kernel distribution key. You can
view the keys to ensure they're what you expect:&lt;/p&gt;
&lt;img alt="/images/secure_boot_3.jpg" class="align-center" src="https://www.setphaserstostun.org/images/secure_boot_3.jpg"&gt;
&lt;p&gt;Here's the information about the selected key:&lt;/p&gt;
&lt;img alt="/images/secure_boot_4.jpg" class="align-center" src="https://www.setphaserstostun.org/images/secure_boot_4.jpg"&gt;
&lt;p&gt;Once you've verified you're enrolling the proper keys choose &lt;cite&gt;Continue&lt;/cite&gt;:&lt;/p&gt;
&lt;img alt="/images/secure_boot_5.jpg" class="align-center" src="https://www.setphaserstostun.org/images/secure_boot_5.jpg"&gt;
&lt;p&gt;You will be asked if you want to enroll the key(s), choose &lt;cite&gt;Yes&lt;/cite&gt;:&lt;/p&gt;
&lt;img alt="/images/secure_boot_6.jpg" class="align-center" src="https://www.setphaserstostun.org/images/secure_boot_6.jpg"&gt;
&lt;p&gt;You will now be asked for the password you used when you enrolled the key using
&lt;strong&gt;mokutil&lt;/strong&gt;. Input the password, you won't need it anymore once this is done:&lt;/p&gt;
&lt;img alt="/images/secure_boot_7.jpg" class="align-center" src="https://www.setphaserstostun.org/images/secure_boot_7.jpg"&gt;
&lt;p&gt;Once you've entered the password it's time to reboot:&lt;/p&gt;
&lt;img alt="/images/secure_boot_8.jpg" class="align-center" src="https://www.setphaserstostun.org/images/secure_boot_8.jpg"&gt;
&lt;/section&gt;
&lt;section id="conclusion"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-12" role="doc-backlink"&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You're done! Your machine should now reboot using the &lt;strong&gt;shim&lt;/strong&gt; bootloader which
will in turn load GRUB. If you had other operating systems such as Windows
these should appear in the menu, as well as other UEFI executables like
&lt;cite&gt;memtest86+&lt;/cite&gt; for example. Booting any of the entries should work and provide
a validated boot chain. Once you've booted back into Gentoo you can always
verify that this is the case by using &lt;strong&gt;mokutil&lt;/strong&gt; again:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mokutil --sb-state
SecureBoot enabled&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="updating-and-troubleshooting"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-13" role="doc-backlink"&gt;Updating and troubleshooting&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You might wonder about how to deal updates to the packages we've used when
setting everything up. Here's how.&lt;/p&gt;
&lt;section id="kernel-updates"&gt;
&lt;h3&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-14" role="doc-backlink"&gt;Kernel updates&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you've setup the &lt;code class="docutils literal"&gt;GRUB_CFG&lt;/code&gt; configuration variable as described above then
the &lt;code class="docutils literal"&gt;grub.cfg&lt;/code&gt; file will be regenerated automatically every time you install
a new kernel (or remove one with &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;eclean-kernel&lt;/span&gt;&lt;/code&gt;). Otherwise you'll have to
regenerate the &lt;code class="docutils literal"&gt;grub.cfg&lt;/code&gt; file by hand and place it alongside the GRUB and
shim executables.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="grub-updates"&gt;
&lt;h3&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-15" role="doc-backlink"&gt;GRUB updates&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/grub&lt;/span&gt;&lt;/code&gt; package is updated you should update your
installation and re-create the configuration file. Note that your system will
keep booting correctly even if you don't, but you'll be running an outdated
bootloader:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# cp /usr/lib/grub/grub-x86_64.efi.signed /boot/efi/EFI/gentoo/grubx64.efi
# grub-mkconfig -o /boot/efi/EFI/gentoo/grub.cfg&lt;/pre&gt;
&lt;p&gt;It is also possible to automatically update GRUB using a post-installation
hook. By using the script below both the GRUB EFI executable and the
configuration file will be automatically replaced whenever you update or
re-install the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/grub&lt;/span&gt;&lt;/code&gt; package. Beware however that if something goes
wrong this might make your machine unbootable and you'll have to fix it by
hand. It's not a big risk but it's worth mentioning it.&lt;/p&gt;
&lt;p&gt;Anyway, let's add the appropriate directories to your portage profile if
they're not already there yet:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mkdir --parents /etc/portage/profile/bashrc /etc/portage/profile/package.bashrc&lt;/pre&gt;
&lt;p&gt;Now we'll add a script in your portage profile that will execute the steps
needed to update the GRUB EFI executable. Copy the following script into
&lt;code class="docutils literal"&gt;/etc/portage/profile/bashrc/grubinstall&lt;/code&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-1" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-1" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-1"&gt;&lt;/a&gt;post_pkg_postinst&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-2" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-2" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;ebegin&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Backing up the GRUB bootloader to /boot/efi/EFI/gentoo/grubx64.efi~"&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-3" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-3" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;mv&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/boot/efi/EFI/gentoo/grubx64.efi"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/boot/efi/EFI/gentoo/grubx64.efi~"&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-4" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-4" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;eend&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-5" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-5" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-6" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-6" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;ebegin&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Backing up the GRUB configuration to /boot/efi/EFI/gentoo/grub.cfg~"&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-7" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-7" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;mv&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/boot/efi/EFI/gentoo/grub.cfg"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/boot/efi/EFI/gentoo/grub.cfg~"&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-8" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-8" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;eend&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-9" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-9" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-10" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-10" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;ebegin&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Installing the GRUB bootloader to /boot/efi/EFI/gentoo/grubx64.efi"&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-11" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-11" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;cp&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/usr/lib/grub/grub-x86_64.efi.signed"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/boot/efi/EFI/gentoo/grubx64.efi"&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-12" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-12" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;eend&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-13" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-13" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-14" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-14" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-14"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;ebegin&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Generating a new GRUB configuration file"&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-15" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-15" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-15"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;grub-mkconfig&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/boot/efi/EFI/gentoo/grub.cfg"&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-16" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-16" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-16"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;eend&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;a id="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-17" name="rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-17" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_0eb72562d4ef46ae8fa9a75e2c2b8018-17"&gt;&lt;/a&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;p&gt;Note that the script contains only one function called &lt;code class="docutils literal"&gt;post_pkg_postinst()&lt;/code&gt;,
it's a hook that portage will run after having installed a package. So now we
have to instruct portage to run this script every time the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/grub&lt;/span&gt;&lt;/code&gt;
package is installed:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# echo "sys-boot/grub grubinstall" &amp;gt; /etc/portage/profile/package.bashrc/grub&lt;/pre&gt;
&lt;p&gt;And you're done.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="shim-bootloader-updates-troubleshooting"&gt;
&lt;h3&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-16" role="doc-backlink"&gt;shim bootloader updates &amp;amp; troubleshooting&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/shim&lt;/span&gt;&lt;/code&gt; package is updated it is highly recommended to also
update your installation. Failing to do so might lead to an unbootable system,
as older versions of the package are progressively marked as unsafe, and new
UEFI firmwares will refuse to boot them. To update the &lt;strong&gt;shim&lt;/strong&gt; bootloader
first update the package then manually copy the new version to the EFI
partition:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# cp /usr/share/shim/mmx64.efi /boot/efi/EFI/gentoo/
# cp /usr/share/shim/BOOTX64.EFI /boot/efi/EFI/gentoo/&lt;/pre&gt;
&lt;p&gt;In particular you'll have to update the &lt;strong&gt;shim&lt;/strong&gt; bootloader if you get a boot
failure with the following error message:&lt;/p&gt;
&lt;pre class="literal-block"&gt;Verifying shim SBAT data failed: security policy violation&lt;/pre&gt;
&lt;p&gt;You won't be able to boot with the existing bootloader and you'll have to
either temporarily disable Secure Boot or boot with another bootloader to fix
the issue. Updating &lt;strong&gt;shim&lt;/strong&gt; will solve the problem.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;shim&lt;/strong&gt; can be updated automatically using the same approach described above
for GRUB. Copy the following script to &lt;code class="docutils literal"&gt;/etc/portage/profile/bashrc/shiminstall&lt;/code&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;div class="code"&gt;&lt;pre class="code bash"&gt;&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-1" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-1" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-1"&gt;&lt;/a&gt;post_pkg_postinst&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-2" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-2" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;ebegin&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Copying /usr/share/shim/BOOTX64.EFI to /boot/efi/EFI/gentoo/BOOTX64.EFI"&lt;/span&gt;
&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-3" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-3" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;cp&lt;span class="w"&gt; &lt;/span&gt;/usr/share/shim/BOOTX64.EFI&lt;span class="w"&gt; &lt;/span&gt;/boot/efi/EFI/gentoo/BOOTX64.EFI
&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-4" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-4" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;eend&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-5" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-5" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-6" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-6" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;ebegin&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Copying /usr/share/shim/mmx64.efi to /boot/efi/EFI/gentoo/mmx64.efi"&lt;/span&gt;
&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-7" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-7" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;cp&lt;span class="w"&gt; &lt;/span&gt;/usr/share/shim/mmx64.efi&lt;span class="w"&gt; &lt;/span&gt;/boot/efi/EFI/gentoo/mmx64.efi
&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-8" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-8" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;eend&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;a id="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-9" name="rest_code_ab6b3840207f4bbd8e82cc2baabfafee-9" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#rest_code_ab6b3840207f4bbd8e82cc2baabfafee-9"&gt;&lt;/a&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;p&gt;And configure portage to run this script every time the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/shim&lt;/span&gt;&lt;/code&gt;
package is installed or updated:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# echo "sys-boot/shim shiminstall" &amp;gt; /etc/portage/profile/package.bashrc/shim&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="windows-dual-boot-troubleshooting"&gt;
&lt;h3&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-17" role="doc-backlink"&gt;Windows dual-boot troubleshooting&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Gentoo currently ships two versions of &lt;strong&gt;shim&lt;/strong&gt;: 15.8 and 16.1. Dual-booting
Windows using the old version works fine but fails with the new one due to an
upstream bug in GRUB.&lt;/p&gt;
&lt;p&gt;At the time of writing Gentoo's GRUB package (&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-boot/grub-2.14-r5&lt;/span&gt;&lt;/code&gt;) does
not contain a fix, but it is possible to patch it to fix the issue by using two
patches shipped with Debian's GRUB package. You'll need to place both patches
under &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;/etc/portage/patches/sys-boot/grub&lt;/span&gt;&lt;/code&gt; and rebuild the package:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# mkdir --parents /etc/portage/patches/sys-boot/grub
# wget -P /etc/portage/patches/sys-boot/grub \
    https://salsa.debian.org/grub-team/grub/-/raw/9cbf984566f08c7b7dc9b5fb26aacec22cdde891/debian/patches/upstream/efi-linux-set-loaded-image-device-path.patch \
    https://salsa.debian.org/grub-team/grub/-/raw/9cbf984566f08c7b7dc9b5fb26aacec22cdde891/debian/patches/upstream/efi-chainloader-set-loaded-image-device-path.patch
# emerge --oneshot sys-boot/grub&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="motherboard-uefi-firmware-updates-troubleshooting"&gt;
&lt;h3&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#toc-entry-18" role="doc-backlink"&gt;motherboard UEFI firmware updates &amp;amp; troubleshooting&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Updating the motherboard UEFI firmware sometimes clears the MOK list. If that's
the case your system will fail to boot and you will have to enroll your key
again. Follow the steps in &lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#reboot-enrolling-the-key-in-the-mok-list"&gt;Reboot &amp;amp; enrolling the key in the MOK list&lt;/a&gt; to
enroll your key once more. Also re-enroll Gentoo's signing key if you're using
a pre-built kernel.&lt;/p&gt;
&lt;p&gt;Similarly sometimes the UEFI boot list will be cleared, removing the &lt;strong&gt;shim&lt;/strong&gt;
boot entry. If it happens repeat the steps in &lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/#creating-a-new-efi-boot-entry"&gt;Creating a new EFI boot entry&lt;/a&gt;
to create a new one.&lt;/p&gt;
&lt;/section&gt;
&lt;/section&gt;</description><category>gentoo</category><category>grub</category><category>linux</category><category>secureboot</category><category>shim</category><guid>https://www.setphaserstostun.org/posts/secure-boot-on-gentoo-with-shim-grub/</guid><pubDate>Thu, 18 Jul 2024 15:38:23 GMT</pubDate></item><item><title>Gentoo 6.1.x generic kernel configuration</title><link>https://www.setphaserstostun.org/posts/gentoo-61x-generic-kernel-configuration/</link><dc:creator>Gabriele Svelto</dc:creator><description>&lt;p&gt;The 6.1.x branch of the Linux kernel has been marked as stable in &lt;a class="reference external" href="https://www.gentoo.org"&gt;Gentoo&lt;/a&gt; for a
few months already and I was busy enough that I forgot to publish an updated
generic kernel configuration for it. As with my previous posts this
configuration is largely based on the Fedora kernel with some Gentoo-specific
tweaks. It supports practically every bit of hardware in existence and enables
a lot of bleeding-edge kernel functionality.&lt;/p&gt;
&lt;p&gt;The only few notable changes compared to the Fedora kernel are the following:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;binfmt_misc&lt;/code&gt; module is baked in for convenience&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The NVMe core modules are baked in so you can boot from an NVMe drive without
having to use an initrd&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;CONFIG_ACPI_EXTLOG&lt;/code&gt; option is enabled. This is useful if you're using
&lt;a class="reference external" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/"&gt;rasdaemon to monitor ECC memory&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The boot logo is disabled&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kernel debugging is disabled&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;CONFIG_GENTOO_KERNEL_SELF_PROTECTION&lt;/code&gt; option is enabled. This
implicitly enables an additional set of security features for hardening the
kernel&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;CONFIG_GENTOO_PRINT_FIRMWARE_INFO&lt;/code&gt; option is enabled, it prints out
the firmwares that are loaded into various bits of hardware. This is useful
if you want to reduce the amount of files installed
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/linux-firmware&lt;/span&gt;&lt;/code&gt; package&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that the &lt;strong&gt;RTC time based on NTP synchronization&lt;/strong&gt; is enabled so - if
you're using OpenRC - you don't need the &lt;strong&gt;hwclock&lt;/strong&gt; service (but you can use
&lt;strong&gt;osclock&lt;/strong&gt; instead if some other service requires the &lt;strong&gt;clock&lt;/strong&gt; facility).&lt;/p&gt;
&lt;p&gt;Additionally note that this kernel configuration is for use with OpenRC. If
you're using systemd you'll have to remove the
&lt;code class="docutils literal"&gt;CONFIG_GENTOO_LINUX_INIT_SCRIPT=y&lt;/code&gt; line from the configuration file and add
&lt;code class="docutils literal"&gt;CONFIG_GENTOO_LINUX_INIT_SYSTEMD=y&lt;/code&gt; instead.&lt;/p&gt;
&lt;p&gt;Now that zstd is well supported in many packages I have enabled it for
compressing kernel modules. The only thing you need to make sure to use it is
that the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-apps/kmod&lt;/span&gt;&lt;/code&gt; package has the &lt;strong&gt;zstd&lt;/strong&gt; &lt;code class="docutils literal"&gt;USE&lt;/code&gt; flag set so that it
can handle the compressed modules. If for some reason you don't want modules
to be compressed set &lt;cite&gt;CONFIG_MODULE_COMPRESS_ZSTD=n&lt;/cite&gt; and
&lt;cite&gt;CONFIG_MODULE_COMPRESS_NONE=y&lt;/cite&gt; respectively.&lt;/p&gt;
&lt;p&gt;To use this configuration file install the latest stable
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-sources&lt;/span&gt;&lt;/code&gt; package (6.1.x), copy the configuration file
under &lt;code class="docutils literal"&gt;/usr/src/linux/&lt;/code&gt; and rename it to &lt;code class="docutils literal"&gt;.config&lt;/code&gt; then proceed to build
and install the kernel as usual.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.setphaserstostun.org/config-6.1"&gt;Gentoo 6.1.x kernel configuration file&lt;/a&gt;&lt;/p&gt;</description><category>gentoo</category><category>kernel</category><category>linux</category><guid>https://www.setphaserstostun.org/posts/gentoo-61x-generic-kernel-configuration/</guid><pubDate>Sun, 26 Nov 2023 07:43:54 GMT</pubDate></item><item><title>Gentoo 5.15.x generic kernel configuration</title><link>https://www.setphaserstostun.org/posts/gentoo-515x-generic-kernel-configuration/</link><dc:creator>Gabriele Svelto</dc:creator><description>&lt;p&gt;The 5.15.11 Linux kernel has been marked as stable in &lt;a class="reference external" href="https://www.gentoo.org"&gt;Gentoo&lt;/a&gt; a few weeks ago
and I've wanted to put out a new generic kernel configuration but I kept
struggling with a really silly issue adapting it. As with my previous posts
this configuration is largely based on the Fedora kernel with some
Gentoo-specific tweaks. It supports practically every bit of hardware in
existence and enables a lot of bleeding-edge kernel functionality.&lt;/p&gt;
&lt;p&gt;The only few notable changes compared to the Fedora kernel are the following:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;binfmt_misc&lt;/code&gt; module is baked in for convenience&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The NVMe core modules are baked in so you can boot from an NVMe drive without
having to use an initrd&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;CONFIG_ACPI_EXTLOG&lt;/code&gt; option is enabled. This is useful if you're using
&lt;a class="reference external" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/"&gt;rasdaemon to monitor ECC memory&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The boot logo is disabled&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kernel debugging is disabled&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;CONFIG_GENTOO_KERNEL_SELF_PROTECTION&lt;/code&gt; option is enabled. This
implicitly enables an additional set of security features for hardening the
kernel&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code class="docutils literal"&gt;CONFIG_GENTOO_PRINT_FIRMWARE_INFO&lt;/code&gt; option is enabled, it prints out
the firmwares that are loaded into various bits of hardware. This is useful
if you want to reduce the amount of files installed
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/linux-firmware&lt;/span&gt;&lt;/code&gt; package&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that the &lt;strong&gt;RTC time based on NTP synchronization&lt;/strong&gt; is enabled (and it's
finally become the default in many other Linux distros) so you don't need the
&lt;strong&gt;hwclock&lt;/strong&gt; service (but you can use &lt;strong&gt;osclock&lt;/strong&gt; instead if some other service
requires the &lt;strong&gt;clock&lt;/strong&gt; facility).&lt;/p&gt;
&lt;p&gt;Additionally note that this kernel configuration is for use with OpenRC. If
you're using systemd you'll have to remove the
&lt;code class="docutils literal"&gt;CONFIG_GENTOO_LINUX_INIT_SCRIPT=y&lt;/code&gt; line from the configuration file and add
&lt;code class="docutils literal"&gt;CONFIG_GENTOO_LINUX_INIT_SYSTEMD=y&lt;/code&gt; instead.&lt;/p&gt;
&lt;p&gt;For maximum compatibility I haven't enabled kernel compression in this
configuration, but I suggest using &lt;code class="docutils literal"&gt;CONFIG_MODULE_COMPRESS_ZSTD=y&lt;/code&gt; as it
provides significant space savings while having effectively no impact on load
times. Just make sure that the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-apps/kmod&lt;/span&gt;&lt;/code&gt; package has the &lt;strong&gt;zstd&lt;/strong&gt;
&lt;code class="docutils literal"&gt;USE&lt;/code&gt; flag set so that it can handle the compressed modules.&lt;/p&gt;
&lt;p&gt;To use this configuration file install the latest stable
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-sources&lt;/span&gt;&lt;/code&gt; package (5.15.x), copy the configuration file
under &lt;code class="docutils literal"&gt;/usr/src/linux/&lt;/code&gt; and rename it to &lt;code class="docutils literal"&gt;.config&lt;/code&gt; then proceed to build
and install the kernel as usual.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.setphaserstostun.org/config-5.15"&gt;Gentoo 5.15.x kernel configuration file&lt;/a&gt;&lt;/p&gt;</description><category>gentoo</category><category>kernel</category><category>linux</category><guid>https://www.setphaserstostun.org/posts/gentoo-515x-generic-kernel-configuration/</guid><pubDate>Tue, 11 Jan 2022 08:12:32 GMT</pubDate></item><item><title>Gentoo 5.10.x generic kernel configuration</title><link>https://www.setphaserstostun.org/posts/gentoo-510x-generic-kernel-configuration/</link><dc:creator>Gabriele Svelto</dc:creator><description>&lt;p&gt;The 5.10.27 Linux kernel has been marked as stable in &lt;a class="reference external" href="https://www.gentoo.org"&gt;Gentoo&lt;/a&gt; a few days ago and
I've just updated my generic kernel configuration file to support it. As with my
previous posts this configuration is based on the Fedora kernel with some
Gentoo-specific tweaks. It supports practically every bit of hardware in
existence and enables a lot of bleeding-edge kernel functionality.&lt;/p&gt;
&lt;p&gt;The only few notable changes compared to the Fedora kernel are the following:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;binfmt_misc&lt;/strong&gt; module is baked in for convenience&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The NVMe core modules are baked in so you can boot from an NVMe drive without
having to use an initrd&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RTC time based on NTP synchronization&lt;/strong&gt; is enabled so you don't need the
&lt;strong&gt;hwclock&lt;/strong&gt; service (but you can use &lt;strong&gt;osclock&lt;/strong&gt; instead if some other service
requires the &lt;strong&gt;clock&lt;/strong&gt; facility)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;CONFIG_ACPI_EXTLOG&lt;/strong&gt; option is enabled. This is useful if you're using
&lt;a class="reference external" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/"&gt;rasdaemon to monitor ECC memory&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The boot logo is disabled&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kernel debugging is disabled&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that this kernel configuration is for use with OpenRC. If you're using
systemd you'll have to remove the &lt;code class="docutils literal"&gt;CONFIG_GENTOO_LINUX_INIT_SCRIPT=y&lt;/code&gt; line
from the configuration file and add &lt;code class="docutils literal"&gt;CONFIG_GENTOO_LINUX_INIT_SYSTEMD=y&lt;/code&gt;
instead.&lt;/p&gt;
&lt;p&gt;To use it install the latest stable &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-sources&lt;/span&gt;&lt;/code&gt; package
(5.10.x), copy the configuration file under &lt;code class="docutils literal"&gt;/usr/src/linux/&lt;/code&gt; and rename it
to &lt;code class="docutils literal"&gt;.config&lt;/code&gt; then proceed to build and install the kernel as usual.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.setphaserstostun.org/config-5.10"&gt;Gentoo 5.10.x kernel configuration file&lt;/a&gt;&lt;/p&gt;</description><category>gentoo</category><category>kernel</category><category>linux</category><guid>https://www.setphaserstostun.org/posts/gentoo-510x-generic-kernel-configuration/</guid><pubDate>Mon, 05 Apr 2021 13:21:12 GMT</pubDate></item><item><title>Monitoring ECC memory on Linux with rasdaemon</title><link>https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/</link><dc:creator>Gabriele Svelto</dc:creator><description>&lt;p&gt;If you have a workstation built around an AMD Ryzen/Threadripper or Intel Xeon
processor chances are you're using &lt;a class="reference external" href="https://en.wikipedia.org/wiki/ECC_memory"&gt;ECC memory&lt;/a&gt;. ECC memory is a worthy
investment to improve the reliability of your machine and if properly monitored
will allow you to spot memory problems before they become catastrophic.&lt;/p&gt;
&lt;p&gt;On recent Linux kernels the &lt;a class="reference external" href="https://github.com/mchehab/rasdaemon"&gt;rasdaemon&lt;/a&gt; tools can be used to monitor ECC memory
and report both correctable and uncorrectable memory errors. As we'll see with a
little bit of tweaking it's also possible to know exactly which DIMM is
experiencing the errors.&lt;/p&gt;
&lt;nav class="contents" id="contents" role="doc-toc"&gt;
&lt;p class="topic-title"&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#top"&gt;Contents&lt;/a&gt;&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#installing-rasdaemon" id="toc-entry-1"&gt;Installing rasdaemon&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#configuring-rasdaemon" id="toc-entry-2"&gt;Configuring rasdaemon&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#configuring-dimm-labels" id="toc-entry-3"&gt;Configuring DIMM labels&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#troubleshooting" id="toc-entry-4"&gt;Troubleshooting&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/nav&gt;
&lt;section id="installing-rasdaemon"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#toc-entry-1" role="doc-backlink"&gt;Installing rasdaemon&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;First of all you'll need to intall &lt;strong&gt;rasdeamon&lt;/strong&gt;, it's packaged for most Linux
distributions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Debian/Ubuntu&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;# apt-get install rasdaemon&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fedora&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;# dnf install rasdaemon&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;openSUSE&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;# zypper install rasdaemon&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gentoo&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The package is currently marked as unstable so you'll need to unmask it first:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# echo "app-admin/rasdaemon ~amd64" &amp;gt;&amp;gt; /etc/portage/package.keywords&lt;/pre&gt;
&lt;p&gt;Then I recommend enabling sqlite support, this makes rasdaemon record events
to disk and is particularly useful for machines that get rebooted often:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# echo "app-admin/rasdaemon sqlite" &amp;gt;&amp;gt; /etc/portage/packages.use&lt;/pre&gt;
&lt;p&gt;Finally install rasdaemon itself:&lt;/p&gt;
&lt;pre class="literal-block"&gt;emerge rasdaemon&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="configuring-rasdaemon"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#toc-entry-2" role="doc-backlink"&gt;Configuring rasdaemon&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Then we'll setup &lt;strong&gt;rasdaemon&lt;/strong&gt; to launch at startup and to record events to
an on-disk sqlite database.&lt;/p&gt;
&lt;p&gt;Note that when booting with Secure Boot enabled, using the kernel lockdown
facility in &lt;strong&gt;confidentiality&lt;/strong&gt; mode will prevent rasdaemon from running. To
use &lt;strong&gt;rasdaemon&lt;/strong&gt; you'll have to use a different lockdown mode, disable
lockdown entirely or disable Secure Boot. You'll find more information in the
&lt;a class="reference internal" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#troubleshooting"&gt;Troubleshooting&lt;/a&gt; section.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Debian/Ubuntu/Fedora/openSUSE and other systemd-based distros&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;# systemctl enable rasdaemon
# systemctl start rasdaemon&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gentoo with OpenRC&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Add the following line to &lt;code class="docutils literal"&gt;/etc/conf.d/rasdaemon&lt;/code&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;RASDAEMON_ARGS=--record&lt;/pre&gt;
&lt;p&gt;Add &lt;code class="docutils literal"&gt;rasdaemon&lt;/code&gt; to the &lt;strong&gt;default&lt;/strong&gt; run-level and start it&lt;/p&gt;
&lt;pre class="literal-block"&gt;# rc-config add rasdaemon default
# rc-config start rasdaemon&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="configuring-dimm-labels"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#toc-entry-3" role="doc-backlink"&gt;Configuring DIMM labels&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;At this point &lt;strong&gt;rasdaemon&lt;/strong&gt; should already be running on your system. You can
now use the &lt;strong&gt;ras-mc-ctl&lt;/strong&gt; tool to query the errors that have been detected.
From now on I will use data from my machine to give an example of the output.&lt;/p&gt;
&lt;pre class="literal-block"&gt;# ras-mc-ctl --error-count
Label                 CE      UE
mc#0csrow#2channel#0  0   0
mc#0csrow#2channel#1  0   0
mc#0csrow#3channel#1  0   0
mc#0csrow#3channel#0  0   0&lt;/pre&gt;
&lt;p&gt;The CE column represents the number of corrected errors for a given DIMM, UE
represents uncorrectable errors that were detected. The label on the left
shows the EDAC path under &lt;code class="docutils literal"&gt;/sys/devices/system/edac/mc/&lt;/code&gt; of every DIMM.&lt;/p&gt;
&lt;p&gt;This is not very readable. Since the kernel has no idea of the physical layout
of your motherboard it will print the EDAC paths instead of the names of the
DIMM slots. We can confirm that the labels are missing with this command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# ras-mc-ctl --print-labels
ras-mc-ctl: Error: No dimm labels for ASUSTeK COMPUTER INC. model PRIME B450-PLUS&lt;/pre&gt;
&lt;p&gt;To identify which DIMM slot corresponds to which EDAC path you will have to
reboot your system with only one DIMM inserted, write down the name of the
slot you insterted it in and then printing out the paths with
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;ras-mc-ctl&lt;/span&gt; &lt;span class="pre"&gt;--error-count&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In my case this was the mapping:&lt;/p&gt;
&lt;pre class="literal-block"&gt;mc#0csrow#0channel#0  DIMM_A1
mc#0csrow#0channel#1  DIMM_A2
mc#0csrow#1channel#1  DIMM_A2
mc#0csrow#1channel#0  DIMM_A1
mc#0csrow#2channel#0  DIMM_B1
mc#0csrow#2channel#1  DIMM_B2
mc#0csrow#3channel#1  DIMM_B2
mc#0csrow#3channel#0  DIMM_B1&lt;/pre&gt;
&lt;p&gt;Note that there's more than one path per DIMM label, that's fine.&lt;/p&gt;
&lt;p&gt;With this data at hand create a text file under &lt;code class="docutils literal"&gt;/etc/ras/dimm_labels.d/&lt;/code&gt;.
You will need to fill it up with the mapping data in the following format:&lt;/p&gt;
&lt;pre class="literal-block"&gt;Vendor: &amp;lt;motherboard vendor name&amp;gt;
Model: &amp;lt;motherboard model name&amp;gt;
  &amp;lt;label&amp;gt;: &amp;lt;mc&amp;gt;.&amp;lt;row&amp;gt;.&amp;lt;channel&amp;gt;&lt;/pre&gt;
&lt;p&gt;You can obtain the motherboard vendor and model name with the following
command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# sudo ras-mc-ctl --mainboard
ras-mc-ctl: mainboard: ASUSTeK COMPUTER INC. model PRIME B450-PLUS&lt;/pre&gt;
&lt;p&gt;The label lines take a string (the name of the physical DIMM slot), then the
numbers in the EDAC path corresponding to the physical slot. You can put
more than one label entry per line by separating them with a semicolon. If a
given label is associated with more than one EDAC path you can add the separate
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;&amp;lt;mc&amp;gt;.&amp;lt;row&amp;gt;.&amp;lt;channel&amp;gt;&lt;/span&gt;&lt;/code&gt; sequences by separating them with a comma.&lt;/p&gt;
&lt;p&gt;In my case the resulting file (&lt;code class="docutils literal"&gt;/etc/ras/dimm_labels.d/asus&lt;/code&gt;) looks like this:&lt;/p&gt;
&lt;pre class="literal-block"&gt;Vendor: ASUSTeK COMPUTER INC.
Model: PRIME B450-PLUS
  DIMM_A1:  0.0.0, 0.1.0;    DIMM_A2:   0.0.1, 0.1.1;
  DIMM_B1:  0.2.0, 0.3.0;    DIMM_B2:   0.2.1, 0.3.1;&lt;/pre&gt;
&lt;p&gt;You can find another example of this, with configuration entries for a bunch of
other motherboards, in the &lt;a class="reference external" href="https://github.com/grondo/edac-utils/blob/master/src/etc/labels.db"&gt;edac-utils&lt;/a&gt; repo.&lt;/p&gt;
&lt;p&gt;Once the file is ready it's time to load the labels in the kernel with the
following command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# ras-mc-ctl --register-labels&lt;/pre&gt;
&lt;p&gt;Printing out labels and error counts will now use the physical DIMM slot names.
This is much better if you need to figure out which of your DIMMs is faulty and
needs to be replaced:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# ras-mc-ctl --print-labels
LOCATION                            CONFIGURED LABEL     SYSFS CONTENTS
                                    DIMM_A1              0:0:0 missing
                                    DIMM_A2              0:0:1 missing
                                    DIMM_A1              0:1:0 missing
                                    DIMM_A2              0:1:1 missing
mc0 csrow 2 channel 0               DIMM_B1              DIMM_B1
mc0 csrow 2 channel 1               DIMM_B2              DIMM_B2
mc0 csrow 3 channel 0               DIMM_B1              DIMM_B1
mc0 csrow 3 channel 1               DIMM_B2              DIMM_B2

# ras-mc-ctl --error-count
Label   CE      UE
DIMM_B2 0       0
DIMM_B1 0       0
DIMM_B1 0       0
DIMM_B2 0       0&lt;/pre&gt;
&lt;p&gt;To persist the DIMM names across reboots load the &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;rac-mc-ctl&lt;/span&gt;&lt;/code&gt; service at
startup:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Debian/Ubuntu/Fedora and other systemd-based distros&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;# systemctl enable ras-mc-ctl
# systemctl start ras-mc-ctl&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gentoo with OpenRC&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;# rc-config add ras-mc-ctl default
# rc-config start ras-mc-ctl&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You're done! After rebooting your system rasdaemon will be continually running
and recording errors. You can use &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;ras-mc-ctl&lt;/span&gt;&lt;/code&gt; to print out a summary of all
the errors that have been seen and recorded. Since the counts are stored on
disk they will be persisted across reboots. Here's some example output from my
machine:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# ras-mc-ctl --summary
Memory controller events summary:
  Corrected on DIMM Label(s): 'DIMM_B1' location: 0:2:0:-1 errors: 5

PCIe AER events summary:
  1 Uncorrected (Non-Fatal) errors: BIT21

No Extlog errors.

No devlink errors.
Disk errors summary:
  0:0 has 6646 errors
No MCE errors.&lt;/pre&gt;
&lt;/section&gt;
&lt;section id="troubleshooting"&gt;
&lt;h2&gt;&lt;a class="toc-backref" href="https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/#toc-entry-4" role="doc-backlink"&gt;Troubleshooting&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;ras-mc-ctl&lt;/span&gt; &lt;span class="pre"&gt;--status&lt;/span&gt;&lt;/code&gt; prints out &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;ras-mc-ctl:&lt;/span&gt; drivers are not loaded&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For &lt;strong&gt;rasdaemon&lt;/strong&gt; to work the EDAC kernel drivers for your particular
machine need to be loaded. They are usually loaded automatically at boot. You
can check out which ones are loaded with this command:&lt;/p&gt;
&lt;pre class="literal-block"&gt;# lsmod | grep edac
amd64_edac_mod         32768  0
edac_mce_amd           28672  1 amd64_edac_mod&lt;/pre&gt;
&lt;p&gt;If the EDAC drivers haven't been loaded automatically either your kernel
doesn't provide one for your machine or you need to manually load it. Check
the &lt;a class="reference external" href="https://www.kernel.org/doc/html/latest/driver-api/edac.html"&gt;EDAC kernel documentation&lt;/a&gt; for more details.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code class="docutils literal"&gt;rasdaemon&lt;/code&gt; fails to start, complaining it can't access the debugfs
filesystem&lt;/p&gt;
&lt;p&gt;You're likely using the kernel lockdown module in &lt;strong&gt;confidentiality&lt;/strong&gt; mode.
When Secure Boot is enabled this will prevent &lt;strong&gt;rasdaemon&lt;/strong&gt; from reading the
files it needs to gather its statistics. &lt;strong&gt;rasdaemon&lt;/strong&gt; can work with kernel
lockdown when using the &lt;strong&gt;integrity&lt;/strong&gt; mode. To switch to &lt;strong&gt;integrity&lt;/strong&gt; mode
add the &lt;cite&gt;lockdown=integrity&lt;/cite&gt; option to the Linux kernel command line in your
boot loader.&lt;/p&gt;
&lt;p&gt;When using &lt;strong&gt;GRUB&lt;/strong&gt; this can usually be achieved by editing
&lt;code class="docutils literal"&gt;/etc/default/grub&lt;/code&gt; and changing the &lt;code class="docutils literal"&gt;GRUB_CMDLINE_LINUX_DEFAULT&lt;/code&gt;
variable to include the option, e.g.:&lt;/p&gt;
&lt;pre class="literal-block"&gt;GRUB_CMDLINE_LINUX_DEFAULT="quiet splash lockdown=integrity"&lt;/pre&gt;
&lt;p&gt;Keep in mind that &lt;strong&gt;integrity&lt;/strong&gt; mode is less strict than &lt;strong&gt;confidentiality&lt;/strong&gt;
mode, as it permits userspace applications to access a fair amount of
information that lives in the kernel. This might not be suitable for some
deployments - such as those that must run untrusted userspace code.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;</description><category>debian</category><category>ecc</category><category>fedora</category><category>gentoo</category><category>linux</category><category>memory</category><category>opensuse</category><category>ubuntu</category><guid>https://www.setphaserstostun.org/posts/monitoring-ecc-memory-on-linux-with-rasdaemon/</guid><pubDate>Thu, 13 Feb 2020 22:31:44 GMT</pubDate></item><item><title>Gentoo 5.4.x generic kernel configuration</title><link>https://www.setphaserstostun.org/posts/gentoo-54x-generic-kernel-configuration/</link><dc:creator>Gabriele Svelto</dc:creator><description>&lt;p&gt;While the 5.4.x Linux kernel hasn't been marked as stable in &lt;a class="reference external" href="https://www.gentoo.org"&gt;Gentoo&lt;/a&gt; yet I've
updated my generic kernel configuration file to match it. As with the previous
config files for &lt;a class="reference external" href="https://www.setphaserstostun.org/posts/gentoo-414x-generic-kernel-configuration/"&gt;4.14.x&lt;/a&gt; and
&lt;a class="reference external" href="https://www.setphaserstostun.org/posts/gentoo-419x-generic-kernel-configuration/"&gt;4.19.x&lt;/a&gt; this configuration is
based on the Fedora kernel with some Gentoo-specific tweaks. It supports
practically every bit of hardware in existence and enables a lot of
bleeding-edge kernel functionality. The downside is that building it will take
a while and the modules will occupy quite a bit of storage.&lt;/p&gt;
&lt;p&gt;Note that this kernel configuration is for use with OpenRC. If you're using
systemd you'll have to remove the &lt;code class="docutils literal"&gt;CONFIG_GENTOO_LINUX_INIT_SCRIPT=y&lt;/code&gt; line
from the configuration file and add &lt;code class="docutils literal"&gt;CONFIG_GENTOO_LINUX_INIT_SYSTEMD=y&lt;/code&gt;
instead.&lt;/p&gt;
&lt;p&gt;To use it install the appropriate &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-sources&lt;/span&gt;&lt;/code&gt; package
(5.4.x), copy the configuration file under &lt;code class="docutils literal"&gt;/usr/src/linux/&lt;/code&gt; and rename it
to &lt;code class="docutils literal"&gt;.config&lt;/code&gt; then proceed to build and install the kernel as usual.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.setphaserstostun.org/config-5.4"&gt;Gentoo 5.4.x kernel configuration file&lt;/a&gt;&lt;/p&gt;</description><category>gentoo</category><category>kernel</category><category>linux</category><guid>https://www.setphaserstostun.org/posts/gentoo-54x-generic-kernel-configuration/</guid><pubDate>Fri, 20 Dec 2019 08:28:11 GMT</pubDate></item><item><title>Gentoo 4.19.x generic kernel configuration</title><link>https://www.setphaserstostun.org/posts/gentoo-419x-generic-kernel-configuration/</link><dc:creator>Gabriele Svelto</dc:creator><description>&lt;p&gt;The 4.19.23 Linux kernel has been marked as stable in &lt;a class="reference external" href="https://www.gentoo.org"&gt;Gentoo&lt;/a&gt; a few days ago and
I've just updated my generic kernel configuration file to match it. As with the
&lt;a class="reference external" href="https://www.setphaserstostun.org/posts/gentoo-414x-generic-kernel-configuration/"&gt;the 4.14.x configuration&lt;/a&gt; I
posted a while ago this configuration is based on the Fedora kernel with some
Gentoo-specific tweaks. It supports practically every bit of hardware in
existence and enables a lot of bleeding-edge kernel functionality. The downside
is that building it will take a while and the modules will occupy quite a bit
of storage.&lt;/p&gt;
&lt;p&gt;To use it install the latest stable &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-sources&lt;/span&gt;&lt;/code&gt; package
(4.19.x), copy the configuration file under &lt;code class="docutils literal"&gt;/usr/src/linux/&lt;/code&gt; and rename it
to &lt;code class="docutils literal"&gt;.config&lt;/code&gt; then proceed to build and install the kernel as usual.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.setphaserstostun.org/config-4.19"&gt;Gentoo 4.19.x kernel configuration file&lt;/a&gt;&lt;/p&gt;</description><category>gentoo</category><category>kernel</category><category>linux</category><guid>https://www.setphaserstostun.org/posts/gentoo-419x-generic-kernel-configuration/</guid><pubDate>Sun, 24 Feb 2019 20:10:28 GMT</pubDate></item><item><title>Gentoo 4.14.x generic kernel configuration</title><link>https://www.setphaserstostun.org/posts/gentoo-414x-generic-kernel-configuration/</link><dc:creator>Gabriele Svelto</dc:creator><description>&lt;p&gt;While the &lt;a class="reference external" href="https://wiki.gentoo.org/wiki/Handbook:Main_Page"&gt;Gentoo Handbook&lt;/a&gt; contains almost every step needed into making a
working &lt;a class="reference external" href="https://www.gentoo.org"&gt;Gentoo&lt;/a&gt; installation the kernel configuration step can be quite
confusing for a new user. Enabling proper hardware support and turning on all
the useful features can be daunting if you're not a developer or simply haven't
encountered the kernel configuration before.&lt;/p&gt;
&lt;p&gt;A good way around it is to use a generic kernel. &lt;a class="reference external" href="https://wiki.gentoo.org/wiki/Genkernel"&gt;genkernel&lt;/a&gt; provides a way to
build a default kernel but I often find its default configuration to be either
out-of-date or missing some important bit.&lt;/p&gt;
&lt;p&gt;So, if you want to get started on Gentoo quickly you might as well use &lt;em&gt;my&lt;/em&gt;
kernel configuration which is based on the Fedora kernel and as such follows an
everything-and-the-kitchen-sink approach. It supports practically every bit of
hardware out there, will work on desktop PCs, laptops and servers, and includes
important security features such as KPTI. The downside is that it's very large
and will take a long time to compile.&lt;/p&gt;
&lt;p&gt;To use it install the latest stable &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;sys-kernel/gentoo-sources&lt;/span&gt;&lt;/code&gt; package
(4.14.x), copy the configuration file under &lt;code class="docutils literal"&gt;/usr/src/linux/&lt;/code&gt; and rename it
to &lt;code class="docutils literal"&gt;.config&lt;/code&gt; then proceed to build the kernel as usual.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.setphaserstostun.org/config-4.14"&gt;Gentoo 4.14.x kernel configuration file&lt;/a&gt;&lt;/p&gt;</description><category>gentoo</category><category>kernel</category><category>linux</category><guid>https://www.setphaserstostun.org/posts/gentoo-414x-generic-kernel-configuration/</guid><pubDate>Thu, 13 Sep 2018 12:24:52 GMT</pubDate></item></channel></rss>