Custom resolution for an Ubuntu Virtual Box guest
Advertisement
I’ve encountered this problem more often than I like to admit: I got an Ubuntu or Debian based Virtual Box guest and I’d like to change the resolution of the Desktop to one not being enabled by default.
Changing the resolution temporary is easy with cvt
and xrandr
.
But making the change reboot persistent without using those commands in a startup script took me hours of searching the web several times as I have little knowledge with X11, only find parts of the solution and never documented the steps needed on my own… yet.
Advertisement
Lets roll it up from behind. Here’s the end result:
/usr/share/X11/xorg.conf.d/10-monitor.conf
Most of this is static and can just be copy ‘n pasted. There are some parts which are dynamic and some parts which might change, I’d document both so I (hopefully) never want to search the web for a solution again.
Dynamic parts:
- The Modeline parts can be achieved via
cvt ${XRES} ${YRES}|tail -1|
as I already mentioned before. - The Modes lines were already mentioned as well:
cvt ${XRES} ${YRES}|tail -1| cut -d ' ' -f2
- You don’t need to set Option “PreferredMode”, but it’s more comfortable.
Parts that might change:
- The Identifier of the Section “Monitor” changed some time in the past. If it does again, it can be achieved via
xrandr |grep 'primary' | cut -d' ' -f1
(as long as there’s only one display) - The Device section might change as well. It’s unlikely and depending on the change the way to obtain the needed values might differ as well, so I’ll update this if I ever encounter a change.
Afterwards restart the Display manager (depends on which flavor of Debian/Ubuntu you are) or just reboot
.