Saturday, May 17, 2008

Virtualbox on Ubuntu


We've been playing with virtualbox on windows as a way of letting students boot LiveCD's without compromising the security of the network.

Virtualbox is a virtualization program that allows you to install and run other operating systems such as Windows from within Linux.

I've used VMware on windows for a long time and it is quite good. Tried parallels on my macbook but really didn't like it and it was a pain to remove.

Virtualbox is available in the ubuntu repositories so we fire up the package manager and install.

It adds a Virtualbox menu item to the Applications, System Tools menu. Now to download the manual in .pdf format and do some reading. We might want to install windows XP or to test out other linux distributions.

As a test let's create a virtual machine to run MS-DOS. So we click on New and enter DOS622 as the name with an OS type of DOS. Virtualbox supports all versions of windows from 3.1 to Vista along with linuxes and others like BSD and Solaris. Will have to try my BeOS cd later.

We reserve a whopping 32mb of memory for the dos VM and create a fixed size disk image of 40mb which was the size in my old exceltronix AT (upgraded from the 20mb seagate ST drive in the XT). VB disk images have the extension .VDI and are created in the user's home directory.

Once the vm is created you have to configure your devices.

We clicked on cd/dvd drive and put a checkmark in mount. Do not enable passthrouigh.
We also mounted the floppy drive. We have dos on CD somewhere in the MS developers cd's but we also have the floppies. We decide not to enable audio for now but the network is enabled by default. Maybe we can load the packet drivers and run gopher or something.


The cd is /dev/cdrom and the floppy is /dev/fd0

We start the machine and the auto capture message is displayed. This means you have to click in the VM window to use the keyboard/mouse with the VM and then use a 'host' key to return to the host operating system. In the windows version the host key was the right CTRL key (the left key does nothing).

We get an error message 'failed to start Dos622 vm'

VirtualBox kernel driver not installed. The vboxdrv kernel module was either not loaded or /dev/vboxdrv was not created for some reason. Please install the virtualbox-ose-modules package for your kernel and execute '/etc/init.d/vboxdrv start' as root.
VBox status code: -1908 (VERR_VM_DRIVER_NOT_INSTALLED).

This may be because we installed the software but did not reboot the machine. So let's do it.

Ok we try again and get a different error - looks like a permissions problem

The VirtualBox kernel driver is not accessible to the current user. Make sure that the user has write permissions for /dev/vboxdrv by adding them to the vboxusers groups. You will need to logout for the change to take effect..
VBox status code: -1909 (VERR_VM_DRIVER_NOT_ACCESSIBLE).

So we goto System, Administration, Users and Groups and click on Manage Groups. We select the vboxusers group and click on Properties. Our account is listed in the group members list so we place a checkmark in the user box and click OK. We have to logout for this to take effect.

Ok a reboot fixes this and now we can run vb. We put in the boot floppy for dos but vb cannot seem to find a bootable medium. We press F12 at the splash screen and get a menu of boot devices:

1) Floppy
2) Hard disk
3) CD-rom
4) Lan

the floppy light goes green but nothing happens. We try unmounting and mounting the floppy.

So we decide to go for a CD based VM using Windows 2000 using 198mb of ram and a 2 gig hard disk. We put in the CD and start the machine. Same error message:

FATAL: no bootable medium found! system halted.

We try and mount the CD. no go. We see that the cdrom has been assigned to /dev/fd0 so we change it to /dev/cdrom and restart the machine.

We get this error message:

FATAL: could not read from the boot medium! system halted.


So let's change cd's to another one. The old cd backup copy could not be read but the original CD worked fine. This time success - we get the windows 2000 blue setup screen.

It finds the 2gig virtual hard disk and formats it with NTFS and then copies the setup files and 'reboots' into the windows 2000 gui and begins the setup.

We answer the usual questions and the system then starts up again and installs devices.

This takes a few minutes and the screen flickers a few time but that is normal. It seems to have restarted the setup as we have to re-enter the product key again.

Ok - now it is booting but has gone into the setup devices routine once more. Enough - let's try 98 next. The same result - can no read from boot medium when you put a cd in and start the VM.

We go into the settings pane and under the General, Advanced tab set the boot order to make the CD/DVD first. The default is floppy first so maybe it tries to read that and never gets to the cd. All versions of windows up to XP can be installed from a floppy. Windows 98 was 1 floppy, windows 2000 was 4 floppies and windows XP is 6 floppies.


Now we have it booting from the win98 cd rom. It had to reboot to format the hard drive VM and now is running the install program. Looks like it will take about 50 minutes - longer than 2000.

Would be interesting to bundle virtualbox with a bunch of emulators such as MAME. I used to the the Basilisk 68k macintosh emulator on windows and it worked very well. Would be neat to have a bunch of virtual machines with non-windows operating systems.

Ok the install program is pretty much done, but now we have a bunch of vertical green and red lines on the screen. This happened as it was going into the detect devices bit - 98 is probably not as good at that as is 2000 or XP. The cd is still spinning and the green line goes on as it reads from the disc so we assume it i
s still working.

Whatever it is doing is requiring a lot of juice - the system fans have just come on, this is the first time that has happened. we decide to power off the vm and to restart it.

The windows 98 splash screen comes up and we login to windows and complete the install by answering some questions. It's now updating the system settings which is taking a long time. First impressions are that this is slow. The host machine has dual xeon cpus running at 2ghz and a 73gig u160 scsi drive but only 1 gig of ram. Maybe we pop in another gig this week. It's a fairly zippy machine running Ubuntu. We will have to try an install of XP to see if that is a faster process.

Well the performance of windows98 under VB is pretty slow. This may be due to the fact it is running in 640x480 16 color vga resolution. We shut down the machine. Maybe XP will be better.

Tomorrow we now try XP using the Dell 1420 laptop instead of the Compaq Evo desktop. First we create an XP machine with 10gig hd and 512mb of ram. We insert the XP cd and click START.

The cd spins and the xp setup screen appears. The blue screen of death follow 'session3_initialization_failed' STOP: 0x0000006F....etc

We try again. Setup crashes with the same message. We decide to read the article at:

http://www.blog.arun-prabha.com/2007/05/07/installing-virtualbox-and-windows-using-virtualbox-in-ubuntu/

to see how it was done.

We decide to click on the Audio setting and enable audio and set it to ALSA audio driver.

One thing was missing - the USB device option. This version is 1.5.0 OSE, the version for windows i used had settings for the usb devices. The article has information on fixing this.

Open a terminal and enter

sudo gedit /etc/init.d/mountdevsubfs.sh

Go to the lines as shown below:

#
# Magic to make /proc/bus/usb work
#
#mkdir -p /dev/bus/usb/.usbfs
#domount usbfs «» /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
#ln -s .usbfs/devices /dev/bus/usb/devices
#mount --rbind /dev/bus/usb /proc/bus/usb

Uncomment the last 4 lines and make it look like below:

#
# Magic to make /proc/bus/usb work
#
mkdir -p /dev/bus/usb/.usbfs
domount usbfs «» /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount --rbind /dev/bus/usb /proc/bus/usb

Close and restart virtualbox. You should see the USB options in the settings. You can add the devices you want.

Arun also has some more information about USB devices on his blog:

Once you attach the Vboxusers group to the users, change permission to access USB devices. Open a terminal and enter

gksudo gedit /etc/udev/rules.d/40-permissions.rules

Change the line that says

SUBSYSTEM==»usb_device», MODE=»0664»

to

SUBSYSTEM==»usb_device», MODE=»0666»

Save and reboot your system

We did not do this as until the install works - why bother?

We decide to try one more time. Setup runs and now we get the Welcome to Setup menu, we select the 10gig 'partition' and format it with NTFS. Was it the lack of audio that caused the previous attempts to fail? Audio should not be a requirement for an operating system.

Setup copies its files and reboots to the xp hd and runs the windows xp gui to complete the install. We answer the usual questions and it begins to install xp. It finishes and reboots into the XP splash screen and the welcome musak. We turn OFF the automatic updates, decided not to resister, create a user etc and boot in xp. Cool - IE takes us to MSN home page - fat chance, we change the default home to google.

You have to press the right CTRL key to switch between virtualbox and Linux. We do this and take a screenshot of xp in action. To get back to xp just click on the screen and the mouse is acquired.

We turn off XP and exit virtualbox. Guess we will have to try Arun's USB tip tomorrow.