Customized resolution for OpenBSD in VirtualBox

       272 words, 2 minutes

When you run an OpenBSD desktop inside VirtualBox, you don’t get the easy “change resolution” feature. Mostly because there is no “VirtualBox Tools” for OpenBSD, AFAIK. But there is a way to get a customized video resolution.

In my particular case, I run VirtualBox on a Windows 10 machine. But the following may apply to Linux and MacOS VirtualBox instances. The VM should be powered off before adding the custom resolution.

Find the VBoxManage tool and register a custom resolution for the OpenBSD VM:

C:\Program Files\Oracle\VirtualBox> VBoxManage.exe setextradata OpenBSD \
  CustomVideoMode1 1360x768x32

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe getextradata OpenBSD
 Key: CustomVideoMode1, Value: 1360x768x32
 Key: CustomVideoMode2, Value: 1366x768x32
 Key: CustomVideoMode3, Value: 1368x768x32
 Key: GUI/LastCloseAction, Value: SaveState
 Key: GUI/LastNormalWindowPosition, Value: 9,40,720,442
 Key: GUI/LastScaleWindowPosition, Value: 640,280,640,480
 Key: GUI/ScaleFactor, Value: 1

Note that for some reason, it is not possible to get 1366×768. That resolution gets wrecked when used. Either 1360×768 or 1368×768 would work. That said, the VM can now be started. Not sure if that matters but the “Graphics Controller” is set to VBoxSVGA.

Connect to the virtual machine and create a specific xorg configuration file to force using the declared resolution:

# mkdir -p /etc/X11/xorg.conf.d
# vi 00-virtualbox-monitor.conf
# X11 configuration for VirtualBox
Section "Device"
  Identifier   "VirtualBox-Card"
  Driver       "vesa"
  VendorName   "InnoTek"
  BoardName    "VirtualBox Graphics Adapter"
EndSection
Section "Monitor"
  Identifier   "VirtualBox-Monitor"
  VendorName   "InnoTek"
  ModelName    "VirtualBox Screen"
  HorizSync    1.0 - 1000.0
  VertRefresh  1.0 - 1000.0
EndSection
Section "Screen"
  Identifier   "VirtualBox-Screen"
  Device       "VirtualBox-Card"
  Monitor      "VirtualBox-Monitor"
  DefaultDepth 24
  SubSection "Display"
    Viewport   0 0
    Depth      24
    #Modes "1368x768" "1360x768" "1280x800" "1024x768"
    Modes  "1360x768"
  EndSubSection
EndSection

Restart xenodm to apply the custom resolution:

# rcctl restart xenodm
xenodm(ok)
xenodm(ok)

That’s All Folks!