VirtualBox OSE on Debian/Ubuntu Linux

Lately, I've been getting quite interested in virtual machines. Namely, Linux/UNIX on Linux. When I got my new T61 laptop, even before, I have been looking forward to virtualizing Linux operating systems. Gentoo, Fedora, OpenSUSE, etc. So, first thing first, find a good virtual machine to run these guests.

I had already known about VirtualBox, so I thought I'd give that a try. To my surprise, VirtualBox OSE was already in the Debian Sid repositories, and it's in Ubuntu Gutsy, so I did an aptitude install, and had it down the pipe and installed on my system in no time flat.

I fired it up. Unfortunately, to my surprise, VirtualBox was complaining that the modules for the kernel were not installed, and that I would not be able to start a virtual guest until they were installed. Bummed, I began searching Google for how to get these modules installed. Again, to my surprise, it was easier than expected. If you're running VirtualBox OSE, and have run into the same issue, which you probably will, here's what you can do on a Debian/Ubuntu system to get VirtualBox and the modules in place:

Now, you should be able to install and run virtual guests with ease. Currently, I hawe Fedora Core 6 installed (for RHEL 5 instruction and learning) and Gentoo (although I'm currently faced with a kernel panic). Future guests will most likely include Open|FreeBSD, OpenSUSE, Ubuntu and OpenSolaris. I can run them simultaneously, although that might be a bit of a resource hog, or one at a time.

The only hiccups that I currently face with this setup, is getting bridged networking functional. I should be able to ping the guest from the host, and ping the host from the guest. Currently, I can only do the latter and not the former. Also, I have installed the guest additions, but I seem to not be able to run a guest at higher than 1024x768. Seeing as though I have 1680x1050, it would be nice to utilize full screen, but it's not working for me, even with Host+G. I'm sure I'll figure it out.

Did you get USB support to work? I don't think it's in the -ose version, but in the puel version. I had it working in Feisty days with 1.4, but 1.5 and gutsy don't seem to like the USB. Just curious if you've had experience. (My windows mobile phone is dying for USB support)

Derek, even on the puel version, my windows mobile phone wouldn't authenticate with vista's mobile device utility. It would show it as a connected usb device and even installed the drivers just fine, but it couldn't sync.

@Derek- USB, apparently, is only supported in the PUEL version, which is rather unfortunate. I can't mount block devices via USB, but plugging in USB input devices, such as keyboards and mice seem to work fine. Hopefully, they will remove this cripple-ware from the OSE.

-About the not being able to up the resolution in the guest. Do the math res_x*res_y*bytes_per_pixel and change the virtual Graphic Card's memory to something larger than that.
-About the bridging. I don't like bridging. What i do is to redirect the ports i want from the host to the guest (while in NAT mode). Download the manual and see how it is done.

Hey Aaron,
parprouted is what you need for easy network bridging.
It is very usefull on laptops where you want to bridge a virtual machine that you want to answer pings on a wireless interface.
I'll have to start working on a parprouted guide. Dont know where to put the guide once i finish it though.
Cheers,
Karl

i also renamed the eth0 device to eth0br so the bridge can be named eth0.

In feisty this can be done in /etc/iftab in gutsy in /etc/udev/rules.d/70-persistent-net.rules

this worked without problems in feisty but was broken after a update about 3 weeks ago or so. the same problem with gutsy. It only works one time (after reboot). There must be some problems with access rights of the tap or tun device.

Here the trick to make Vbox fullscreen and to get all features working...

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.

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.

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.

It 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.