<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Secure Boot on blog.szypowi.cz</title><link>https://blog.szypowi.cz/tags/secure-boot/</link><description>Recent content in Secure Boot on blog.szypowi.cz</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Fri, 15 May 2020 10:04:54 +0100</lastBuildDate><atom:link href="https://blog.szypowi.cz/tags/secure-boot/index.xml" rel="self" type="application/rss+xml"/><item><title>Testing and signing kernel for Ubuntu 20.04</title><link>https://blog.szypowi.cz/p/testing-and-signing-kernel-for-ubuntu-20.04/</link><pubDate>Fri, 15 May 2020 10:04:54 +0100</pubDate><guid>https://blog.szypowi.cz/p/testing-and-signing-kernel-for-ubuntu-20.04/</guid><description>
 &lt;blockquote&gt;
 &lt;p&gt;&lt;strong&gt;Disclaimer.&lt;/strong&gt; This is about mainline kernel builds, summarized from the Ubuntu wiki:&lt;/p&gt;
&lt;p&gt;By default, Ubuntu systems run with the Ubuntu kernels provided by the Ubuntu repositories. However it is handy to test unmodified upstream kernels to help locate problems in Ubuntu kernel patches, or to confirm that upstream has fixed a specific issue. These kernels are not supported and are not appropriate for production use.&lt;/p&gt;

 &lt;/blockquote&gt;
&lt;h2 id="install-a-mainline-kernel-via-ppa"&gt;Install a mainline kernel via PPA
&lt;/h2&gt;&lt;p&gt;Detailed official instructions: &lt;a class="link" href="https://wiki.ubuntu.com/Kernel/MainlineBuilds" target="_blank" rel="noopener"
 &gt;https://wiki.ubuntu.com/Kernel/MainlineBuilds&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There is a semi-automated wrapper that makes this much less painful:
&lt;a class="link" href="https://github.com/pimlie/ubuntu-mainline-kernel.sh" target="_blank" rel="noopener"
 &gt;https://github.com/pimlie/ubuntu-mainline-kernel.sh&lt;/a&gt;&lt;/p&gt;
&lt;h3 id="install-an-rc-release"&gt;Install an RC release
&lt;/h3&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo ubuntu-mainline-kernel.sh --rc -i
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="mok-keys-secure-boot"&gt;MOK keys (Secure Boot)
&lt;/h2&gt;&lt;p&gt;If you installed Ubuntu 20.04 with Secure Boot enabled &lt;strong&gt;and&lt;/strong&gt; chose to install third-party drivers, you were probably asked to enroll a new key in MOK. That key is then used to sign new kernel modules automatically. It lives at:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ ls /var/lib/shim-signed/mok/
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MOK.der MOK.priv
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To sign the kernel itself you need the key in PEM form:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ &lt;span class="nb"&gt;cd&lt;/span&gt; /var/lib/shim-signed/mok
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ sudo openssl x509 -in MOK.der -inform DER -outform PEM -out MOK.pem
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="sign-the-kernel"&gt;Sign the kernel
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Sign the &lt;code&gt;vmlinuz&lt;/code&gt; of your choice:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo sbsign --key /var/lib/shim-signed/mok/MOK.priv &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --cert /var/lib/shim-signed/mok/MOK.pem &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /boot/vmlinuz-&lt;span class="o"&gt;[&lt;/span&gt;KERNEL-VERSION&lt;span class="o"&gt;]&lt;/span&gt;-generic &lt;span class="se"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; --output /boot/vmlinuz-&lt;span class="o"&gt;[&lt;/span&gt;KERNEL-VERSION&lt;span class="o"&gt;]&lt;/span&gt;-generic.signed
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy the initrd so it pairs with the signed vmlinuz:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo cp /boot/initrd.img-&lt;span class="o"&gt;[&lt;/span&gt;KERNEL-VERSION&lt;span class="o"&gt;]&lt;/span&gt;-generic&lt;span class="o"&gt;{&lt;/span&gt;,.signed&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update GRUB:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo update-grub
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="reboot-and-test"&gt;Reboot and test
&lt;/h2&gt;&lt;p&gt;Pick the &lt;code&gt;.signed&lt;/code&gt; entry in GRUB. If the system boots cleanly and you want to keep the configuration, overwrite the unsigned files with the signed ones and run &lt;code&gt;update-grub&lt;/code&gt; again:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo mv /boot/vmlinuz-&lt;span class="o"&gt;[&lt;/span&gt;KERNEL-VERSION&lt;span class="o"&gt;]&lt;/span&gt;-generic&lt;span class="o"&gt;{&lt;/span&gt;.signed,&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo mv /boot/initrd.img-&lt;span class="o"&gt;[&lt;/span&gt;KERNEL-VERSION&lt;span class="o"&gt;]&lt;/span&gt;-generic&lt;span class="o"&gt;{&lt;/span&gt;.signed,&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo update-grub
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item></channel></rss>