Short and Sweet
sudo apt-get install virtualbox-ose
gpasswd -a yourusername vboxusers
# Log out and back in at this point
sudo /etc/init.d/vboxdrv restart
# See below for instructions on tweaking an Ubuntu Guest OS
My terrible experience getting Rails installed on Ubuntu prompted me to toy around with virtualization. Virtualization allows me to test installation and setup procedures off of a fresh install of Ubuntu. I like this idea because it means I can make my setups repeatable. I’ve had too many installation projects (especially with Gentoo) where I get it working, but have no idea how I got there. But the best part of virtualization is if I screw up the virtual machine, I can load up an earlier snapshot and retry. This is much better than nuking my entire laptop.
My hard time installing Rails made me want to install VirtualBox. As luck would have it, this install was not straight forward either. A plain sudo apt-get install virtualbox-ose did not successfully install VirtualBox for me on my Ubuntu install. Here are the extra steps I had to take to get it working.
Install VirtualBox
This page on the Ubuntu wiki makes out the VirtualBox install to be a simple apt-get and then adding yourself to the vboxusers group. Easy enough.
sudo apt-get install virtualbox-ose
This install went ok for a while but then I saw this scroll by in the console
chown: `:vboxusers': invalid group
* Cannot change owner vboxusers for device /dev/vboxdrv.
Well that’s not cool. What was even more perplexing was that post-install I checked my system and the vboxusers group did exist. I’m not sure if this is a quirk with my system or an actual bug. I went ahead and added myself to the vboxusers group anyway.
gpasswd -a yourusername vboxusers
I logged out and back in, then gave running VirtualBox a try. I started creating a virtual machine, which went well for a while until it gave me an error about the vboxdrv kernel module. After some snooping I came across this Ubuntu bug report which didn’t apply to me but did give me the idea of restarting the module.
sudo /etc/init.d/vboxdrv restart
I tried creating a virtual machine again and VIOLA! Everything worked!
After installing Ubuntu on a virtual machine it’s a good idea to install VirtualBox Guest Additions as well. The below instructions, unless specified otherwise, deal with an Ubuntu Guest OS / virtual machine. Don’t run these commands in your Host OS.
Install VirtualBox Guest Additions
The Guest Additions package installs some add-ons into the Guest OS. The most noticeable of these is Mouse Integration which allows the mouse to function without the need to ‘lock’ it into the VM. I also believe that the Guest Additions install special display drivers. This is important if you want your VirtualBox to run in higher resolutions. I pulled these instructions from the official VirtualBox documentation. It’s a PDF. I don’t know why. They also want you to run the script with sh but why bother?
In the Guest window, that is, the window that is displaying your Guest OS, do Devices -> Install Guest Additions. VirtualBox will prompt you to download the .iso if you haven’t already. After the download finishes you will be prompted to mount the ISO in your VM. Say yes. Run this on the command line of the Guest OS.
sudo /media/cdrom0/VBoxLinuxAdditions.run
The VirtualBox documentation says you can choose which drivers you want to install. If you’re interested in this take a look at sudo /media/cdrom0/VBoxLinuxAdditions.run help
I shut down the Guest OS and took a snapshot at this point. I planned on fiddling with Xorg configurations next and it is much easier to load up a VM snapshot than it is to restore a backup xorg.conf.
Change the VirtualBox Resolution
After my Ubuntu install, Xorg was configured to only support 800×600. This was way too small for me. My main machine is a widescreen laptop running at 1680×1050. I want two options.
- 1024×768 for running VirtualBox windowed
- 1680×1050 for running VirtualBox fullscreen
The VirtualBox documentation has the following to say about running higher resolutions in your VM (page 50 if you’re curious)
VirtualBox can use any default X graphics mode which fits into the virtual video memory allocated to the virtual machine, as described in chapter 3.7.1, General settings, page 37. You can also add your own modes to the X server configuration file. You simply need to add them to the “Modes” list in the “Display” subsection of the “Screen” section.
In your Guest OS, edit your xorg.conf file by running sudo gedit /etc/X11/xorg.conf. Here is what I ended up with.
Section "Screen"
Identifier "Default Screen"
Device "Generic Video Card"
Monitor "Generic Monitor"
DefaultDepth 24
SubSection "Display"
Modes "1680x1050" "1024x768" "800x600"
EndSubSection
EndSection
I rebooted to make sure things worked. I then shut down the Guest OS and took another snapshot.
I am not an Xorg expert. I found if I listed 1680×1050 first Ubuntu’s login screen would be 1680×1050. After logging into my user account I was able to do System -> Preferences -> Screen Resolution and change to 1024×768 without problems. If instead I listed 1024×768 first Ubuntu’s login screen would be 1024×768. After logging in if I attempted to change the Screen Resolution to 1680×1050 (I believe) the horizontal sync would be set incorrectly. By this I mean I couldn’t see jack. I tried figuring out a way to have the default be 1024×768 with the option of switching to 1680×1050, but after an hour of tweaking I gave up. If you are more familiar with Xorg and know what I’m doing wrong, please leave a comment.
Notes
- The Ubuntu install DVD decided that the VM’s max resolution should be 800×600. This, hilariously, is too small to click on the Forward and Ok buttons in the install wizard. I had to figure out that Alt-F went forward in the dialogs. The final dialog needed an Enter to start the install.
- As of this writing, the version of VirtualBox that is installed by virtualbox-ose is 1.5.0.
$ dpkg-query --show virtualbox-ose virtualbox-ose 1.5.0-dfsg2-1ubuntu3It looks like the Ubuntu guys are currently working on getting a VirtualBox 1.5.4 package up. I suppose if you really wanted to, you could install VirtualBox 1.5.4 from source. I found this guide to install from source, but didn’t bother with it.
- I still need to figure out how VirtualBox network bridging works. My VM does have net access because it is able to download packages from online repositories with apt-get. At the same time I couldn’t do something simple like ping my web server. Apparently this is expected. Page 58 of the VirtualBox documentation says: Please note that the ping utility does not work over NAT. There is another option, host interface networking, that might give me more control over the VM’s networking.



February 26th, 2008 at 5:06 am
Thanks for writing this! I too hit the 800×600 problem (I’m Guesting Ubuntu on Vista), and couldn’t figure out how to move the install wizard forward.