Forcing a screen resolution of an Ubuntu guest OS in VirtualBox

I figured that doing this would be trivial but turns out it took a little work:

I’m trying to emulate an official 7″ Raspberry Pi Touch Display in a VM, so for this post the target resolution is 800 x 480. If you want to change it to another resolution swap in yours for the rest of this guide.

First, make sure Auto-resize Guest Display is deselected in Virtualbox:

Run the following command in your terminal:

cvt 800 480 60

The output should look something the the following, starting with Modeline

Copy the text after Modeline so in this case it would be

"800x480_60.00" 29.50 800 824 896 992  480 483 493 500 -hsync +vsync

And paste it after the following command:

xrandr --newmode

NOTE! You may want to change the 800x480_60.00 to something without an underscore in it, it was causing problems on my system. I changed it to pidisplay. The resulting command for this example is:

xrandr --newmode "pidisplay" 29.50 800 824 896 992  480 483 493 500 -hsync +vsync

You should be able to run the above command without error. Next, run:

xrandr -q

You’ll be greeted with output similar to this. Note the name of the display device, in this case VGA-1.

With that output name, enter the following two commands:

xrandr --addmode VGA-1 pidisplay
xrandr --output VGA-1 --mode pidisplay

After running that second command, the window should jump to it’s new resolution! You’re done!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.