Back in April(?) of this year when I got my AMD RX 6700XT graphics card I came across FreeBSD still not supporting the card. So, I switched my desktop to OpenBSD. In that same step, I had to fix Windows because it put some of its bootcode on my FreeBSD drive. Long story short, I switched to Linux to do my gaming for a few months because Windows wouldn’t install. My last desktop died, and over time found Linux didn’t fit my needs entirely and switched back to Windows.

Windows Install Woes

Windows is dumb. In the installer, I went to wipe my Linux drive (good luck figuring out which drive is which for starters…​disk 1,2,3 is SO descriptive). When I selected the option to configure my now empty drive to be my install target, Windows complained that my System partition was too small. What System partition? This is an empty drive!

…​ahhh…​ said I, when I realized Windows wanted to be the only OS on my machine. In other words, it said "that OTHER System partition must go", being my OpenBSD EFI partition. I wanted Windows, so I had no choice. Bye bye OpenBSD EFI partition. I had Windows up and running, now to fix OpenBSD since it was no longer bootable with the EFI stuff gone.

Fixing OpenBSD Bootcode

This part was a little tricky. I think this could have been easily achieved by booting into the OpenBSD live installer, but after talking with some people on the OpenBSD Matrix channel, I learned you can point to the existing drive at the boot> prompt from a live USB. Allegedly, at the boot> prompt you coan type diskinfo and get your disks listed? Didn’t work for me anyway. But I found out that typing boot hd1a:/bsd booted straight to my OpenBSD installation! It was just like I had never screwed up its boot code. For you it could be hd2a or hd3a or whatever so if you don’t get the expected outcome, try incrementing the drive number.

Now I was in my system…​now what? Allegedly, installboot(8) is supposed to be a solution, as it says in the man page

installboot installs bootstrap on the specified disk

That didn’t work for me. With uncertainty, I went to the Using fdisk section of the OpenBSD FAQ where it says:

A totally blank disk will need to have the master boot record's boot code written to the disk before it can boot. Normally, all you need to do is:

Followed by the command:

# fdisk -iy sd0

In the past, I did this following the GPT section shown below in the Full Disk Encryption section. There, it specifies the command for GPT for UEFI booting is different:

# fdisk -gy -b 960 sd0

So, I did that since my drive is in fact sd0. Did a reboot and bing bang boom, my computer booted OpenBSD again!

If You Read This In The Future

I wanted to make a note here that since this is a "how to fix X" article to always reference the latest documentation WITHIN OpenBSD and their FAQ pages in case anything changes. But, if you landed in the same predicament as me and don’t want to nuke your install, this should be your fix.