Boot OpenBSD with EFI for full resolution display

I got a new radeon graphic card for gaming. Unfortunately it’s not supported yet by the radeon(4) driver on OpenBSD. Luckily there’s a workaround: booting with UEFI. UEFI does all the talking with the graphics card, and this allows OpenBSD to use the screen’s full resolution on unsupported cards: it should work better than the vesa(4) driver. EFI boots the operating system differently than old school BIOS: it uses a special partition for the operating system’s bootloader.

First I needed to enable UEFI. It wasn’t called UEFI or EFI in the BIOS setup but something like “Windows 8 / 10 boot method”, I picked the regular version not the WHQL.

Second I created the EFI system partition to store the EFI bootloaders with gparted: I made a 100 MB partition formatted as FAT32 at the beginning of the disk, then set the flags “boot” & “esp” on it.

Third I created the system’s partition and did the install via a USB stick a usual. Once the install was done and before rebooting, I copied the OpenBSD’s EFI bootloader to the EFI system partition like this:

# mount /dev/sd0i /mnt2
# mkdir -p /mnt2/efi/boot
# cp /mnt/usr/mdec/BOOTX64.EFI /mnt2/efi/boot

I rebooted and it worked out of the box: OpenBSD can now use my Radeon RX 570 and my 2560×1440 screen at full resolution.