Thursday, October 13, 2011

Change Ubuntu 11.04 Screen Resolution in Virtualbox

To change screen resolution in Ubuntu 11.04 in Virtualbox:

1. Install Virtualbox Guest additions. Devices→Install Guest Additions...
2. Configure X

Ubuntu 11.04 no longer has the /etc/X11/xorg.conf file that you may be familiar with using to configure your video driver and screen resolution. In Ubuntu 11.04 the sections of the xorg.conf file are split apart into separate conf files in the /usr/share/X11/xorg.conf.d/ directory.

My default 11.04 installation's /usr/share/X11/xorg.conf.d/ contains:
10-evdev.conf
11-evdev-quirks.conf
50-synaptics.conf
50-vmmouse.conf
50-wacom.conf
51-synaptics-quirks.conf

These conf files correspond to devices that were autodetected by X and may be different on your system.

To configure the screen resolution we need to add a section for the monitor. Using your favorite editor create a file called /usr/share/X11/xorg.conf.d/10-monitor.conf.
sudo gedit /usr/share/X11/xorg.conf.d/10-monitor.conf

Enter the following into the conf file:
Section "Monitor"
Identifier "Monitor0"
EndSection

Section "Device"
Identifier "Device0"
Driver "vboxvideo"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1400x768"
EndSubSection
EndSection

Where I put 1400x768 choose whatever resolution you desire and reboot the VM.

If something goes wrong and X does not start after you reboot you'll be stuck at the initialization screen. To revert your change press ctrl+alt+f1 to enter a console. Login with your regular credentials and tweak the /usr/share/X11/xorg.conf.d/10-monitor.conf file. You may have chosen a resolution or bit depth that the virtual box driver isn't happy with. My install wouldn't run with a 32 bit depth.

To see more information to help you solve any problems, run
less /var/log/Xorg.0.log

This log will show you the problems that X had while trying to load. I used the log to read the autodetected settings and figure out that I needed to use the "vboxvideo" driver.

Hope this helps.