Open BSD Vitrualbox Screen Resolution Workaround

How to Adjust Screen Resolution on Open BSD in Virtualbox 


Introduction

One of the first thing that you will want to do after installing Open BSD on Virtualbox is to adjust the screen resolution. But if you go to the view menu you see that the resize options are disabled. Well there is good news and bad news...I'll start with the bad news: Virtualbox guest additions does not support Open BSD but the good news is with some custom scripts and hacking we can simply resize the screen resolutions to what we want. I have created two scripts to solve the issue.


This is the first script that is that we are going to execute on the host machine.



#!/bin/sh

if [ -z "$1" ] || [ -z "$2" ]; then
	echo "Pass VBox machine name and screen resolution"
	echo "Example: 'OpenBSD New' '1920x1080x32'"
	exit 1
fi

VBoxManage setextradata "$1" CustomVideoMode1 "$2"

result=`VBoxManage getextradata "$1" CustomVideoMode1`

case "$result" in
*$2*) VBoxManage getextradata "$1" CustomVideoMode1 && echo success;;
*       ) echo failure ;;
esac


This is the second script that we are going to run it inside of the Open BSD.



#!/bin/sh


if [ "$(id -u)" -ne 0 ]; then
    echo "This script must be run as root"
    exit 1
fi

mkdir -p /etc/X11/xorg.conf.d

cat << EOF > /etc/X11/xorg.conf.d/00-virtualbox-monitor.conf
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  "$1"
  EndSubSection
EndSection
EOF

echo "Success - reboot your system"


So all you have to do is save the shell scripts to each machine (customize first if needed) and then execute the scripts. I will go over the rest of this process now.

On The Host machine

I power off my virtual machine and bring up my terminal so on the host. I will chmod +x the script and if you execute the script without passing any parameter it tells you that you need to specify two parameters.... the first one is the name of the virtual machine that you want to set the screen resolution for, and the second option is the desirable screen resolution to set the screen resolution on the machine. We need to pass the s switch and then type the name of the virtual machine here in my case my VM is named Puffdaddy. Make sure to wrap the name and the screen resolution in single quotation then as the screen resolution you can pass anything. My screen is full HD so I specify full HD 32-bit color. We are done with the host machine... now we have to start the Open BSD VM and run the second script.

Inside The OpenBSD VM

Switch to the root user then make sure that the script is executable with chmod +x (after customizing script to meet your requirements). Specify the desirable resolution in my case again full HD and then you shoould a success message. What the script does is it creates a file under x11 directory xorg and then this is the file we show a box monitor conf and then it sets the resolution that has been specified by you in the script. Now restart your machine and check whether everything works as expected.


Final Notes

After restarting the OpenBSD virtual machine you will now have a much larger workspace. Hopefully this enriches your Open BSD expirience and has helped you solve the issue with Virtual Box VM resolution & Open BSD.