Skip to content
Henryk Paluch edited this page Jun 11, 2024 · 5 revisions

OpenBSD on UEFI

Here is my early experience with OpenBSD on UEFI.

Common notes

Only .img (raw disk for USB stick, etc.) supports both BIOS and UEFI. In my example I used:

NOTE: OpenBSD ISO images work in BIOS mode only. You may not use them for UEFI.

Fixing insane screen resolution

OpenBSD wscons by default switches to maximum available resolution - which is totally insane. Here is what resolution is used under Proxmox 8.1-3:

# from dmesg:
efifb0 at mainbus0: 2048x2048, 32bpp

To fix it to mode 2 (800x600) under Proxmox you can use:

a) when in boot (prompt boot> loader try:

# command below will list available modes
machine gop
# command below will force mode 2 (800x600):
machine gop 2
boot

b) to make this change persistent, try:

# after boot run as root:
echo "machine gop 2" >> /etc/boot.conf

Hyper-V Generation 2

Fixed here:

--- usr/src/sys/dev/acpi/dsdt.c.orig	Tue Dec 19 07:49:12 2023
+++ usr/src/sys/dev/acpi/dsdt.c	Wed Dec 20 07:43:05 2023
@@ -3742,7 +3742,7 @@
  	struct acpi_dsdt *p_dsdt;
  	struct acpi_q *entry;

-	if (strlen(rootpath) > 0)
+	if (strlen(rootpath) > 1 || ( strlen(rootpath)==1 && *rootpath != '\\') )
  		aml_die("LoadTable: RootPathString unsupported");
  	if (strlen(parameterpath) > 0)
  		aml_die("LoadTable: ParameterPathString unsupported");

Please note that only Serial console seems to work so far, but not efifb0 Console (it stays blank all the time).

Does not work in my case - there is hidden panic message.

Hypervisor: Windows Server 2012R2 with Hyper-V Role, Generation 2 (UEFI) Guest: OpenBSD 7.4/amd64

Here is how to get debugger with panic:

  • Download installation image from: https://cdn.openbsd.org/pub/OpenBSD/7.4/amd64/install74.img

  • convert it to VHDX using command like:

    qemu-img convert -p -f raw -O vhdx install74.img obsd74-uefi.vhdx
  • under Hyper-V Create Generation 2 VM and attach above VHDX file as existing disk

  • disable Secure Boot under Firmware

  • before starting VM create Virtual COM port to see messages and panic - in PowerShell:

    Set-VMComPort VM_NAME 1 \\.\pipe\HyperPipe
  • now start VM and press space to halt boot> prompt

  • run Putty and select connection type Serial and enter \\.\pipe\HyperPipe as Serial line name

  • now back on Hyper-V in boot> type:

    set tty com0
    
  • you should see now prompt in Putty.

  • now boot Generic kernel using this command:

    boot 7.4/amd64/bsd
    
  • after while you should see early boot and panic.

boot> boot 7.4/amd64/bsd
cannot open hd0a:/etc/random.seed: No such file or directory
booting hd0a:7.4/amd64/bsd: 17163596+4137992+363792+0+1236992 [1342507+128+13178                                                               40+1011174]=0x1959a68
entry point at 0x1001000
[ using 3672680 bytes of bsd ELF symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2023 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 7.4 (GENERIC) #1336: Tue Oct 10 08:52:22 MDT 2023
    deraadt@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC
real mem = 1036947456 (988MB)
avail mem = 985939968 (940MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0x3fdf1000 (12 entries)
bios0: vendor Microsoft Corporation version "Hyper-V UEFI Release v1.0" date 11/                                                               26/2012
bios0: Microsoft Corporation Virtual Machine
efi0 at bios0: UEFI 2.3.1
efi0: EDK II rev 0x10000
acpi0 at bios0: ACPI 4.0
acpi0: sleep states S0 S5
acpi0: tables DSDT FACP APIC OEM0 WAET OEM1 SRAT BGRT
acpi0: wakeup devices
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee00000
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 11, 24 pins
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+, 2000.27 MHz, 0f-4b-02
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CF                                                               LUSH,MMX,FXSR,SSE,SSE2,SSE3,CX16,HV,NXE,MMXX,FFXSR,LONG,3DNOW2,3DNOW,LAHF,CMPLEG                                                               ,AMCR8
cpu0: 64KB 64b/line 2-way D-cache, 64KB 64b/line 2-way I-cache
cpu0: 512KB 64b/line 16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 200MHz
acpihve0 at acpi0
LoadTable: RootPathString unsupported
0034 Called: \_SB_._INI
0034 Called: \_SB_._INI
panic: aml_die aml_loadtable:3746
Stopped at      db_enter+0x14:  popq    %rbp
    TID    PID    UID     PRFLAGS     PFLAGS  CPU  COMMAND
*     0      0      0     0x10000      0x200    0  swapper
db_enter(10,ffffffff829605c0,286,8,ffffffff81835b24,ffffffff829605c0)
 at db_enter+0x14
panic(ffffffff820e210e,ffffffff820e210e,ffffffff8209b736,ea2,ffffffff824a18c2,ffffffff829605d0)
 at panic+0xbc
_aml_die(ffffffff8209b736,ea2,ffffffff820c2fd5,ffffffff8209b736,ffff80000002e148,ffff80000002e158)
 at _aml_die+0x3e7
aml_loadtable(ffff800000029400,ffff80000002e138,ffff80000002e148,ffff80000002e158,ffff80000002e168,ffff80000002e178)
 at aml_loadtable+0x1f0
aml_parse(ffff800000041088,54,ffff800000041088,ffff800000041088,8b6e818bf00372aa,ffff800000041088)
 at aml_parse+0xab5
aml_eval(0,ffff800000030288,74,0,0,0)
 at aml_eval+0x301
aml_evalnode(ffff800000029400,ffff800000030208,0,0,0,ffff800000029400)
 at aml_evalnode+0xb8
acpi_inidev(ffff800000030208,ffff800000029400,50be2c891493ae1a,ffffffff81db7b50,ffff800000029400,ffffffff820ce20b)
 at acpi_inidev+0x6e
aml_find_node(ffff80000002be08,ffffffff820ce20b,ffffffff81db7b50,ffff800000029400,3f2da558de4bb6c9,ffffffff81db7b50)
 at aml_find_node+0x84
aml_find_node(ffffffff825679c0,ffffffff820ce20b,ffffffff81db7b50,ffff800000029400,3f2da558dee5b49f,ffffffff82960a80)
 at aml_find_node+0xd1
acpi_attach_common(ffff800000029400,3fdfa014,be11230416b4dc44,ffff80000002b500,ffffffff82960ca0,ffffffff824951a0)
 at acpi_attach_common+0x607
config_attach(ffff80000002b500,ffffffff824a9470,ffffffff82960ca0,ffffffff81cefcc0,1be10fea7e145b1d,ffffffff82960c60)
 at config_attach+0x1f4
bios_attach(ffff80000002b480,ffff80000002b500,ffffffff82960dc8,ffff80000002b480,a29e677d6a51afb1,ffff80000002b480)
 at bios_attach+0x77e
config_attach(ffff80000002b480,ffffffff824a3970,ffffffff82960dc8,ffffffff819ccb70,1be10fea7e467a4f,ffffffff82960dc8)
 at config_attach+0x1f4
end trace frame: 0xffffffff82960e70, count: 0
https://www.openbsd.org/ddb.html describes the minimum info required in bug
reports.  Insufficient info makes it difficult to find and fix bugs.
ddb>
ddb> show panic
*cpu0: aml_die aml_loadtable:3746

and that's all so far...

Published here:

Proxmox VE

You have to create two disks (used Virtio BLK)

  1. target disk for installation (used 25GB)
  2. installation disk (1GB)

Here is output of qm config VM_ID:

agent: 1
bios: ovmf
boot: order=virtio0;virtio1
cores: 1
cpu: host
efidisk0: local-lvm:vm-101-disk-0,efitype=4m,size=4M
hotplug: 0
ide2: none,media=cdrom
memory: 2048
meta: creation-qemu=8.1.2,ctime=1702896927
name: obsd74-uefi
net0: virtio=BC:24:11:F0:EA:5D,bridge=vmbr0
numa: 0
ostype: l26
scsihw: virtio-scsi-single
smbios1: uuid=60c7a4f6-c2ec-46ed-98d2-e923d3231a49
sockets: 1
vga: qxl
virtio0: local-lvm:vm-101-disk-1,cache=unsafe,discard=on,iothread=1,size=25G
virtio1: local-lvm:vm-101-disk-2,discard=on,iothread=1,size=1G
vmgenid: 5fd0f0fd-412c-433b-98c0-1aed5b4fd885

Important settings:

  • BIOS: Use OVMF (UEFI) (the only UEFI mode)
  • Machine: Use i440fx, found that when using Q35 the keyboard is not working and you will be NOT able to type characters!
  • all disks are of type Virtio BLK

Before install you have to:

  • note empty installation disk - in our case it is this line:
    virtio1: local-lvm:vm-101-disk-2,discard=on,iothread=1,size=1G
  • copy install74.img to that disk, for example (when it is on lvm-thin):
    # DOUBLE CHECK of=.... name !!!
    dd if=iso/install74.img bs=1024k of=/dev/pveiron/vm-101-disk-2 status=progress

LibVirt virt-manager

Similar to Proxmox:

  • Chipset: i440FX
  • Firmware: UEFI x86_64 /usr/share/qemu/ovmf-x86_64-ms-code.bin
  • when VM is booted for the first time, press ESC to enter SETUP and turn OFF Secure Boot (it is enabled by default which is problem)
    • I did not find knob in Virt-Manager to do that outside VM...

Source code of EFI boot loader

Boot loader is on FAT partition called ESP (must be always GPT disk partitioning for UEFI)

  • can be mounted with something like (if your boot disk is sd0):
    mkdir -p /mnt/efi
    mount -r -t msdos /dev/sd0i /mnt/efi
  • installed as efi/BOOT/BOOTX64.EFI.
  • prepared binary is in /usr/mdec/BOOTX64.EFI
  • installer (installboot command) source is under /usr/src/usr.sbin/installboot)
  • source code is in kernel tree: /usr/src/sys/arch/amd64/stand/efiboot
Clone this wiki locally