ubuntu VirtualBox screen resolution

I’m trying out ubuntu on my Windows 7 laptop under VirtualBox and I’d like to switch to full screen mode on my Toshiba laptop which is 1366×768 and on my desktop system which is 1920×1200.

Before you start this process, you must have the VirtualBox Guest Additions installed.  Execute the command:

$ sudo apt-get install build-essential linux-headers-$(uname -r)

Then shutdown your Ubuntu guest. If you’re running in a very high resolution, like 1920×1200, you must also configure the VirtualBox Guest to give it 128Mb of display memory. Do this in the VB Manager under Settings > Display.

If you still can’t get the resolution you want, try the following:

$ sudo apt-get install virtualbox-ose
$VBoxManage controlvm winbox setvideomodehint 1920 1200 24

What follows are the instructions using xrandr but the steps above worked for me under Ubuntu 10.10.

My first step was to setup the modes for the System > Preferences > Monitors tool. I found a very good description of the steps on the ubuntu geek site. Execute the xrandr command to get the name of your display which is used as a parameter in several of the commands.

$ xrandr
Screen 0: minimum 640 x 480, current 1024 x 768, maximum 1024 x 768
VBOX0 connected 1024×768+0+0 0mm x 0mm
1024×768 61.0*
800×600 61.0
640×480 60.0

You’ll replace all references to VGA1 in the commands to VBOX0. Here’s a summary of the steps creating a new resolution of 1366×768:

$ cvt 1366 768
# 1368×768 59.88 Hz (CVT) hsync: 47.79 kHz; pclk: 85.25 MHz
Modeline “1368x768_60.00” 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync

The Modeline output from the cvt command should be passed as a parameter to the xandr command as shown here:

$ xrandr –newmode “1368x768_60.00” 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
$ xrandr –addmode VBOX0 1368x768_60.00
$ xrandr –output VBOX0 –mode 1368x768_60.00

To make the changes permanent, you need to edit the default file to insert the commands that we just executed.

$ gksudo gedit /etc/gdm/Init/Default

Insert the commands in the file after these lines

PATH=/usr/bin:$PATH
OLD_IFS=$IFS

$ xrandr –newmode “1368x768_60.00” 85.25 1368 1440 1576 1784 768 771 781 798 -hsync +vsync
$ xrandr –addmode VBOX0 1368x768_60.00
$ xrandr –output VBOX0 –mode 1368x768_60.00

After following these steps, switch your VirtualBox ubuntu VM into full screen mode either via the Machine > Switch to Fullscreen menu item or Host Key + F.