all repos — aaoth.xyz @ 206bcf1dd46728974d203099a6f037129f960181

aaoth.xyz website

blog: rewrite article in better words
la-ninpre leobrekalini@gmail.com
Fri, 03 Feb 2023 16:53:45 +0300
commit

206bcf1dd46728974d203099a6f037129f960181

parent

985f453ce9e49cc85bd96ed9625ca536cfc9d58b

1 files changed, 44 insertions(+), 34 deletions(-)

jump to
M en/blog/2021-11-03-dualboot-linux-and-openbsd-with-grub.mden/blog/2021-11-03-dualboot-linux-and-openbsd-with-grub.md

@@ -10,8 +10,6 @@

i've been trying to dualboot openbsd with linux using grub on both bios and uefi machines and here's a solution that i've come up with. -<!--more--> - there are some guides about this on the internet, but there'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's specifying drives

@@ -22,54 +20,66 @@ (which happened).

all partitions and drives have their unique identifier -- uuid. there's no direct way to specify uuid in grub configuration, but there is a workaround. - -grub manual describes the `search` command which has an option to set root +grub manual describes the `search` command which has an option to set the root device if it is found. so we can use it for our purposes. -## steps for dualbooting in bios/legacy mode +## dualbooting in bios/legacy mode -1. install linux system on one of your drives +this guide assumes that you have two drives, one of which has linux system installed +and another has openbsd installed. -2. reboot and boot from openbsd install media and install openbsd to other drive -or partition. +on linux system, use commands like `blkid` or `lsblk -f` to get a list of drives with +their uuids. there should be a partition with type 'ufs2' on a drive with openbsd installed. +write down or copy uuid of that partition. -3. reboot and login to your linux system +depending on your linux distribution, you may have different options to edit +the grub config file. many distributions provide `/etc/grub.d` directory, which +has separate files that then get combined into `/boot/grub/grub.cfg`. if you have it, +then you can edit the `/etc/grub.d/40_custom` file, which is a good place +for custom boot options and such. if it is not your case, you can edit `grub.cfg` directly, +but note that it may be overwritten on a system update. -4. open a terminal and run `blkid` or `lsblk -f` to get an output partition -uuids. +add this to your grub config (`40_custom` or `grub.cfg`, see above): -5. write the following at the bottom of `/etc/grub.d/40_custom`: +```grub.cfg - ```grub.cfg +menuentry 'OpenBSD' { + search -sun <UUID> + chainloader +1 +} +``` - menuentry 'OpenBSD' { - search -su --no-floppy *UUID* - chainloader +1 - } - ``` +where \<UUID\> is the uuid of your openbsd partition (with type 'ufs2'). - where *UUID* is the uuid of your openbsd partition (with type 'ufs2') +you can review options for a `search` command in grub'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). -6. run either `update-grub` or `grub-mkconfig` depending on what distribution -you are using. consult your distro's wiki to find a way to update your grub -configuration with recent changes. +if you edited the `40_custom` file, don't forget to run `grub-mkconfig` or `update-grub` +(check your distribution's manual on updating the grub configuration). -7. now reboot and you should see an openbsd's boot option in grub menu. +after rebooting, you should see openbsd boot option in grub menu. -## steps for uefi system +## dualbooting in uefi/gpt mode -for boot in uefi mode there are few differences. after installing openbsd -don't reboot, but choose **shell**. now cd into `/mnt` directory and -download `BOOTX64.EFI` from your desired openbsd mirror. for example: +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. + +as with bios/legacy boot described earlier, you need to add a boot option to grub, +but this time it's a bit different: -```sh +```grub.cfg -# cd /mnt -# ftp https://cdn.openbsd.org/pub/OpenBSD/7.0/amd64/BOOTX64.EFI -# reboot +menuentry 'OpenBSD' { + search -sun <UUID> + chainloader /efi/boot/bootx64.efi +} ``` -after that the only other difference is that `chainloader` directive should -be `chainloader /BOOTX64.EFI`. +where \<UUID\> is the uuid of openbsd's fat12 partition. + +don't forget to update grub configuration if you edited `40_custom` file. -all other steps are the same. +this also works even if you used full-disk encryption on openbsd.