all repos — aaoth.xyz @ fd04ca488dcad2ae680d229af5ba8c6dfaa5f0e3

aaoth.xyz website

en/blog/2021-11-03-dualboot-linux-and-openbsd-with-grub.md (view raw)

 1# dualboot linux and openbsd with grub
 2
 3```data
 4
 5date: 2021-11-03
 6author: la-ninpre
 7tags: openbsd, linux, grub, tutorial
 8```
 9
10i've been trying to dualboot openbsd with linux using grub on both bios and
11uefi machines and here's a solution that i've come up with.
12
13<!--more-->
14
15there are some guides about this on the internet, but there's no single guide
16that covers both bios and uefi. @rootbsd has a video where he shows how to
17do this, but his solution has one little disadvantage. he's specifying drives
18in a grub config using relative drive and partition numbers, such as
19`(hd0,gpt2)`. since these numbers could be different if one inserts a new drive
20to the computer, or changes drive order, the boot option could fail
21(which happened).
22
23all partitions and drives have their unique identifier -- uuid. there's no
24direct way to specify uuid in grub configuration, but there is a workaround.
25
26grub manual describes the `search` command which has an option to set root
27device if it is found. so we can use it for our purposes.
28
29## steps for dualbooting in bios/legacy mode
30
311. install linux system on one of your drives
32
332. reboot and boot from openbsd install media and install openbsd to other drive
34or partition.
35
363. reboot and login to your linux system
37
384. open a terminal and run `blkid` or `lsblk -f` to get an output partition
39uuids.
40
415. write the following at the bottom of `/etc/grub.d/40_custom`:
42
43  ```grub.cfg
44
45  menuentry 'OpenBSD' {
46      search -su --no-floppy *UUID*
47      chainloader +1
48  }
49  ```
50
51  where *UUID* is the uuid of your openbsd partition (with type 'ufs2')
52
536. run either `update-grub` or `grub-mkconfig` depending on what distribution
54you are using. consult your distro's wiki to find a way to update your grub
55configuration with recent changes.
56
577. now reboot and you should see an openbsd's boot option in grub menu.
58
59## steps for uefi system
60
61for boot in uefi mode there are few differences. after installing openbsd
62don't reboot, but choose **shell**. now cd into `/mnt` directory and
63download `BOOTX64.EFI` from your desired openbsd mirror. for example:
64
65```sh
66
67# cd /mnt
68# ftp https://cdn.openbsd.org/pub/OpenBSD/7.0/amd64/BOOTX64.EFI
69# reboot
70```
71
72after that the only other difference is that `chainloader` directive should
73be `chainloader /BOOTX64.EFI`.
74
75all other steps are the same.