💾 Archived View for aaoth.xyz › rss.xml captured on 2024-02-05 at 09:36:19.

View Raw

More Information

⬅️ Previous capture (2023-12-28)

-=-=-=-=-=-=-

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="/rss.xml" rel="self" type="application/rss+xml" />
<title>aaoth.xyz - feed</title>
<description>various notes about things.</description>
<link>/rss.xml/</link>
<lastBuildDate>Sun, 26 Nov 2023 00:00:00 +0100</lastBuildDate>

<item>
<guid>/2021-11-03-dualboot-linux-and-openbsd-with-grub.html</guid>
<link>/2021-11-03-dualboot-linux-and-openbsd-with-grub.html</link>
<pubDate>Wed, 03 Nov 2021 00:00:00 +0100</pubDate>
<title>dualboot linux and openbsd with grub</title>
<description><![CDATA[

<h1 id="dualboot-linux-and-openbsd-with-grub">dualboot linux and openbsd with grub</h1>

<pre><code class="language-data">
date: 2021-11-03
author: la-ninpre
tags: openbsd, linux, grub, tutorial
</code></pre>

<p>i&#8217;ve been trying to dualboot openbsd with linux using grub on both bios and
uefi machines and here&#8217;s a solution that i&#8217;ve come up with.</p>

<p>there are some guides about this on the internet, but there&#8217;s no single guide
that covers both bios and uefi. @rootbsd has a video where he shows how to
do this, but his solution has one little disadvantage. he&#8217;s specifying drives
in a grub config using relative drive and partition numbers, such as
<code>(hd0,gpt2)</code>. since these numbers could be different if one inserts a new drive
to the computer, or changes drive order, the boot option could fail
(which happened).</p>

<p>all partitions and drives have their unique identifier &#8211; uuid. there&#8217;s no
direct way to specify uuid in grub configuration, but there is a workaround.
grub manual describes the <code>search</code> command which has an option to set the root
device if it is found. so we can use it for our purposes.</p>

<h2 id="dualbooting-in-bioslegacy-mode">dualbooting in bios&#47;legacy mode</h2>

<p>this guide assumes that you have two drives, one of which has linux system installed
and another has openbsd installed.</p>

<p>on linux system, use commands like <code>blkid</code> or <code>lsblk -f</code> to get a list of drives with
their uuids. there should be a partition with type &#8216;ufs2&#8217; on a drive with openbsd installed.
write down or copy uuid of that partition.</p>

<p>depending on your linux distribution, you may have different options to edit
the grub config file. many distributions provide <code>&#47;etc&#47;grub.d</code> directory, which
has separate files that then get combined into <code>&#47;boot&#47;grub&#47;grub.cfg</code>. if you have it,
then you can edit the <code>&#47;etc&#47;grub.d&#47;40_custom</code> file, which is a good place
for custom boot options and such. if it is not your case, you can edit <code>grub.cfg</code> directly,
but note that it may be overwritten on a system update.</p>

<p>add this to your grub config (<code>40_custom</code> or <code>grub.cfg</code>, see above):</p>

<pre><code class="language-grub.cfg">
menuentry &#39;OpenBSD&#39; {
    search -sun &#60;UUID&#62;
    chainloader +1
}
</code></pre>

<p>where &#60;UUID&#62; is the uuid of your openbsd partition (with type &#8216;ufs2&#8217;).</p>

<p>you can review options for a <code>search</code> command in grub&#8217;s info page,
but basically they are needed to use uuid instead of drive number,
to set the root variable and to avoid searching floppies (which is not required,
but added just in case).</p>

<p>if you edited the <code>40_custom</code> file, don&#8217;t forget to run <code>grub-mkconfig</code> or <code>update-grub</code>
(check your distribution&#8217;s manual on updating the grub configuration).</p>

<p>after rebooting, you should see openbsd boot option in grub menu.</p>

<h2 id="dualbooting-in-uefigpt-mode">dualbooting in uefi&#47;gpt mode</h2>

<p>openbsd creates few partitions if you choose gpt partitioning scheme during installation.
one of these partitions has fat12 file system and is of our interest.
on linux side you need to get its uuid.</p>

<p>as with bios&#47;legacy boot described earlier, you need to add a boot option to grub,
but this time it&#8217;s a bit different:</p>

<pre><code class="language-grub.cfg">
menuentry &#39;OpenBSD&#39; {
    search -sun &#60;UUID&#62;
    chainloader &#47;efi&#47;boot&#47;bootx64.efi
}
</code></pre>

<p>where &#60;UUID&#62; is the uuid of openbsd&#8217;s fat12 partition.</p>

<p>don&#8217;t forget to update grub configuration if you edited <code>40_custom</code> file.</p>

<p>this also works even if you used full-disk encryption on openbsd.</p>

]]></description>
</item>
</channel></rss>