VirtualBox is a great piece of open source software that allows you to run a wide variety of operating systems as virtual machines on the host operating system. I’ve only ever run VirtualBox under Windows but developed a hankering to run it on my headless Fedora Linux home server. And apparently, this can be done! Here’s how.

First, you need to make sure you have the right package dependencies satisfied.

yum install binutils qt gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms

Okay.

This is geared towards Fedora Linux, but aside of the package manager specific stuff on installing VirtualBox, you should be able to install and run VirtualBox on any flavour of Linux if you know it’s package manager syntax.

yum install VirtualBox

If you’re using CentOS or some other RedHat-based distribution and the VirtualBox package cannot be found, you can install the repo file manually straight from VirtualBox itself.


cd /etc/yum.repos.d/
wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
yum update
yum install VirtualBox-4.2

Right – that was easy. You will probably find that you also need the VirtualBox kernel module installed for this magic to happen. If you pre-loaded the module beforehand, no worries but like me, I’m guessing you haven’t :-)

/etc/sysconfig/modules/VirtualBox.modules

If this doesn’t work or you’re not using Fedora, you can try: -

/etc/init.d/vboxdrv setup

or..
service vboxdrv setup

The above will automatically create vboxusers group and user and also search and automatically rebuild required kernel modules. If the below build process fails, you will get a warning messages. Please have a look at “/var/log/vbox-install.log” to trace why the build process failed.

For this example, I’m going to install the 32-bit version of Ubuntu 10.10 Server with 1GB of RAM and a 10GB hard disk. The first step will be to download the ISO image from Ubuntu.com. So make a directory for your VirtualBox stuff and download the ISO file there.


mkdir ~/vbox
cd ~/vbox
wget http://old-releases.ubuntu.com/10.10/ubuntu-10.10-server-i386.iso

Now that you have the Ubuntu 10.10 Server installation CD file image, you can create your virtual machine and register it with VirtualBox. I’m using the VM name of “Ubuntu-10-10-Server-32″ but you can use whatever you like for the name.

VBoxManage createvm --name "Ubuntu-10-10-Server-32" --register

Next, we set up some basic parameters for the virtual machine. As stated previously, this VM is going to be assigned 1GB of RAM. We’re also going to set the virtual DVD drive as the first boot device so that we can link it to the ISO file and begin the installation when the virtual machine starts up. We also set the first network card to bridged networking so that it gets it’s own IP address separate from the host OS and link it to the “eth0″ network adapter. Bridged networking means that any virtual machine running will try to obtain an IP address from the same source your currently active default network address got its IP address. Hence the term bridged, as the two are connected. If you want to, you can assign it to “eth1″ or whatever is appropriate, but the default for Linux is “eth0″ normally.

VBoxManage modifyvm "Ubuntu-10-10-Server-32" --memory 1024 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0

The next step is to create a virtual hard disk and assign it a size. We want our VDI to be 10GB, so modify the registered VM accordingly. I’ve named the VDI file as the same as the name of the virtual machine we’ve created:-

VBoxManage createhd --filename Ubuntu-10-10-Server-32.vdi --size 10000

You also need to create a virtual IDE controller. You can obviously create a SATA controller instead if you prefer but for the purposes of this demonstration, we’ll use IDE.

VBoxManage storagectl "Ubuntu-10-10-Server-32" --name "IDE Controller" --add ide

he last step here is to attach the newly created IDE controller to the hard disk. We’ll use IDE port 0 for this.

VBoxManage storageattach "Ubuntu-10-10-Server-32" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium Ubuntu-10-10-Server-32.vdi

We’ll also use the IDE controller to link the DVD drive to our ISO image file so that the operating system installation can initialise.

VBoxManage storageattach "Ubuntu-10-10-Server-32" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium ubuntu-10.10-desktop-i386.iso

We’re also going to set some miscellaneous virtual machine settings like the the amount of video RAM available to the graphics card – in this case, 256MB – and setting 3D acceleration and audio controller drivers.

VBoxManage modifyvm "Ubuntu-10-10-Server-32" --vram 256 --accelerate3d on --audio alsa --audiocontroller ac97

One final thing to do is to install the VirtualBox Extension pack – it’s on the download page. Make sure you download the version appropriate for your version of VirtualBox. Oracle has modularised some functionality of VirtualBox since version 4.0 and the extension pack is required for remote desktop connection support (VRDP) which we’ll need in order to complete the installation of the virtual operating system.

You’ll need to be root for this, so:-


su - root
wget http://download.virtualbox.org/virtualbox/4.2.12/Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack

Once you’ve downloaded the extension pack, install it with the following: -


VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack

Now you can drop back down to a normal user by typing “exit”. Aside from installing the extension pack, everything else can be achieved as a normal Linux user. Now that the extension pack is installed, you can set up the virtual remote desktop connection. Here, I’m using a non-standard port of 45005, but if you’re happy to use the default port (3389) you can omit the “vrdeport” parameter. Just make sure you have set your Fedora host OS’s firewall to accept the connection.

VBoxManage modifyvm "Ubuntu-10-10-Server-32" --vrde on --vrdeport 45005

Now you can fire up your virtual machine to continue the OS installation. You can either use the Screen utility to manage your terminal sessions or (as I have done below) load the VirtualBox process into background with “nohup” and the “&” on the end.

nohup VBoxHeadless --startvm "Ubuntu-10-10-Server-32" &

Now you can either use rdesktop to connection via RDP or use Windows’ Remote Desktop Connection client. Either way, if you’re on a non-standard port you’d use: -

rdesktop [YOUR_HOST_IP_ADDRESS]:[PORT]

This will connect you to your VM via the host IP address on which you’re running VirtualBox to continue the installation. If, upon boot, you get the following error (as I did):-

piix4_smbus 0000.00.07.0: SMBus base address uninitialized - upgrade bios or use force_addr=0xaddr

Don’t worry about this for now. It’s an annoying warning but doesn’t affect anything at this point. Once the virtual machine OS is installed, we can fix this easily. Go through your usual Ubuntu installation procedure and then once the login prompt appears, switch windows back to your host Fedora bash prompt and power down the VM with: -

VBoxManage controlvm "Ubuntu-10-10-Server-32" poweroff

We’re powering off the VM because we need to detach the ISO installation file for this Ubuntu VM, else every time we fire up the virtual machine, it’ll load the ISO installation media again and now Ubuntu is installed we want to boot straight into the VM. You can find out the information on which IDE (in this case – it could be SATA) controllers are currently attached to the VM by running: -

VBoxManage showvminfo "Ubuntu-10-10-Server-32"

This will display a bunch of information about the current state of the VM. The line you’re looking for looks something like: -


Storage Controller Name (0): IDE Controller
Storage Controller Type (0): PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0): 2
Storage Controller Port Count (0): 2
Storage Controller Bootable (0): on
IDE Controller (0, 0): /home/vboxuser/vbox/Ubuntu-10-10-Server-32.vdi (UUID: 3e097b88-5feb-45c7-9e63-2b7a6610dd4f)
IDE Controller (1, 0): /home/vboxuser/vbox/ubuntu-10.10-server-i386.iso (UUID: 51c9864e-0427-492e-871e-a93109fd0d86)

You can now detach this device with: -

VBoxManage storageattach "Ubuntu-10-10-Server-32" --storagectl "IDE Controller" --port 1 --device 0 --medium emptydrive

If you run “vminfo” again, you’ll see the virtual DVD drive is now empty.


Storage Controller Name (0): IDE Controller
Storage Controller Type (0): PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0): 2
Storage Controller Port Count (0): 2
Storage Controller Bootable (0): on
IDE Controller (0, 0): /home/vboxuser/vbox/Ubuntu-10-10-Server-32.vdi (UUID: 3e097b88-5feb-45c7-9e63-2b7a6610dd4f)
IDE Controller (1, 0): Empty

Okay, now that’s taken care of, fire up the virtual machine again and use rdesktop or Microsoft’s RDP utility to log back into your VM. If you want to make things easier for yourself at this point you could set up the SSH server and log straight into your VM via your Fedora command line SSH client. Either way, you should now have shell access to your Ubuntu 10.10 virtual server. Once you’ve logged in, you can find out your VM’s IP address in the usual fashion with:-

ifconfig

This is far from ideal, but I’ve not found any way to get the bridged network IP address from the host OS command line as of yet. A call to “vminfo” fails to show the IP address of the running guest VM. If anybody knows how to do this, please leave a comment!

If you’ve not got that smbus base address error, you’re done – congratulations! Enjoy your Ubuntu virtual machine running in Fedora :-)

Now to fix that annoying “piix4_smbus 0000.00.07.0: SMBus base address uninitialized – upgrade bios or use force_addr=0xaddr” error (assuming this is a problem for you). It’s only a warning and doesn’t actually affect anything, but it would be nice not to have it. This error is caused by the Ubuntu VM having no smbus but Ubuntu always trying to load the kernel module anyway. So let’s disable that. First, check that the module is being loaded with:-

lsmod | grep i2c_piix4

If so, you need to disable it. Open the following file in “vi” or whatever your favourite text editor is:-

vi /etc/modprobe.d/blacklist.conf

and add the line: -

blacklist i2c_piix4

Now reinitialise the RAMDisk with:-

update-initramfs -u -k all

Done. No more error.

Leave a Reply

Search The Node
The Node Downloads
Xbox LIVE Gamertag