Ubuntu 9.10 and Sun VirtualBox

As part of my C programming course recently I needed a Linux environment to work in, so decided to give Sun VirtualBox a try as a way to run Ubuntu 9.10 on my Laptop (running Windows 7).  It works well, but required a little tweaking to get going properly.

First, you need to install guest additions - to do this you need to choose it from the devices menu at the top of the VirtualBox window... this mounts them as a virtual CD ROM drive in your Linux install.

From there, you need to open a command shell (Applications - Accessories - Terminal) and run the appropriate Linux version as Root:

cd /media/cdrom0

sudo ./VBoxLinuxAdditions-x86.run

This will (among other things) give you better screen resolutions (System - Preferences - Display) than 800 x 600, but not the correct one for a full screen most likely.  So, to add resolutions that will actually be useful you'll need to add an xorg.conf file with appropriate resolutions.  Follow these instructions, and copy - paste the following config, modifying the resolution from 1024 x 768 to suit your screen size.

Open a command shell, as above, then do the following:

cd /etc/X11

sudo vim xorg.conf

Then hit the 'i' key, which puts vim in 'insert' mode (if you know how to use vim or vi then ignore this and just do it).  now highlight and copy the code below, then click back in the shell and then right click.  this may or may not auto-paste it - if not choose paste from the menu.

Section "Device"
    Identifier   "Configured Video Device"
    Driver       "vboxvideo"
EndSection

Section "Screen"
    Identifier   "Default Screen"
    Device       "VirtualBox graphics card"
    Monitor      "Generic Monitor"
    DefaultDepth 24
    SubSection "Display"
        Depth        24
        Modes        "1024x768"
    EndSubSection
EndSection

Now hit ESC to go back to command mode, then type

:wq

Which tells vim to save the file and quit.

Reboot, and you should now have that resolution as an option in the display settings (System - Preferences - Display)

And, as a footnote, updating the OS will possibly break this - it did break mine.  Simply install the guest additions again and it should resolve it.