This document provides information on using the VirtualBox system emulator in Ubuntu. VirtualBox can run a "guest" operating system in a window of the host operating system without giving it direct access to your computer's hardware. (Instead, Virtualbox passes hardware-related instructions through the "host" operating system's drivers.) VirtualBox can run all versions of Windows, Linux, and many other x86- and AMD/Intel-based 32- and 64-bit operating systems as either a host OS or as a guest OS. Although some versions of Linux (including Ubuntu) exist that are optimized to run as a guest OS in a virtual environment, any Linux operating system usually will function equally well.

Some typical reasons to use a Virtual Machine include

  • providing a self-contained environment in which to experiment with new software without risking damaging changes to the host operating system
  • to run legacy operating systems and software that may no longer be supported by newer operating systems

No special hardware is required to run a virtual machine, although recent processors have virtualization "hooks" which interact specifically with virtual machines to improve performance.

Installation and configuration

See:

Using Virtual Box

The VirtualBox can be run from the menu Applications > System Tools > A kernel module is started when the host computer is booted, but nothing happens until you manually start a virtual machine. This can be automated by a script, but by default, if you reboot your host, your guest machines will not be running any more.

For help getting started, VirtualBox/FirstVM describes setting up an Ubuntu guest using VirtualBox.

Un-Grabbing the mouse & keyboard

In the bottom right hand corner of the emulated machine window is the name of the key required to make Virtual Box un-grab the mouse and keyboard. By default this is Control_R which actually means the right hand Control key, not control and the letter R.

Networking

VirtualBox 2.0 and onwards provides straightforward networking allowing IP address assignment and internet access using NAT, the default network option. See VirtualBox/Networking for more sophisticated set-ups, and information for older versions of Ubuntu and VirtualBox.

USB

VirtualBox/USB describes setting up USB devices. This allows the guest vm to use USB devices plugged into your host.

Sharing Folders Between Host and Guest

VirtualBox/SharedFolders describes sharing folders on the host with guests. This is the Virtual Box method, but others are available, such as standard samba, nfs, and using internet-based storage. The VirtualBox method is optimised Samba.

Using VirtualRDP (VRDP) to View Guest VMs

It is possible to make RDP (Remote Desktop Protocol) connections to virtual machines. This is typically used when accessing a virtual machine on a different computer, because the host computer can display the console directly, and this provides a more fluid user experience. See VirtualBox/RDP for more information.

Installing Virtualbox in Windows

The reason to install Virtualbox in Windows is so that Ubuntu Linux can be run as a guest OS within the virtual machine.

Virtualbox (by Sun) has some advantages and disadvantages. There is a free proprietary edition as well as a subscription-based enterprise edition. The free edition only allows usage of a 32-bit operating system (as the guest OS) whereas the subscription edition allows a 64-bit guest OS. (Both require registration.) There is also has a free open source edition, but this is not easy to install in Windows (unlike in Linux). Virtualbox is available for all operating system platforms, and therefore a virtual machine created in one operating system (Windows, Apple, Linux) can be used in another. Furthermore, it is possible to convert virtual machines created in Virtualbox to VMWare and vice versa.

I find both the installation process and the interface for Virtualbox quite user friendly.

  • Obtain and download a copy of the Virtualbox (binary) installer for your (Windows) operating system here.

  • Install the program, following the prompts.
  • Start Virtualbox

Start menu -> Programs -> Sun Virtualbox -> Virtualbox

(Optional: Of course, if you would like Virtualbox to start every time you run Windows, you can copy the Virtualbox shortcut into the Start menu -> Programs -> Startup folder.)

  • Create a new virtual machine:

Virtualbox -> New -> Next ->

Name: UbuntuVirtualServer

Operating System: Linux

Version: Ubuntu

-> Next -> Memory: Base memory size: 1024 Mb

Note: Use the amount of RAM for the virtual machine that you can afford. Linux requires less memory to run than does Windows, but the amount of RAM that you dedicate to the virtual machine in this step will not be available to the Windows host. On my laptop, I have 3 Gb RAM, so I dedicate 1024 Mb (1 Gb) to the virtual machine in this step and leave 2 Gb for Windows. You should always leave at least 1 Gb RAM for Windows (or it will run painfully slowly). Linux is able to run with only 512 Mb in server mode or 1 Gb in desktop mode (perhaps even less).

-> Next -> Virtual Hard Disk ->

Boot Hard Disk (Primary Master): (ticked)

Create new hard disk: (ticked)

-> Next -> Next -> Hard disk storage type:Dynamically expanding storage: (ticked)

-> Next -> Virtual Disk Location and Size:

Location: UbuntuVirtualServer

Size: 8.00 GB

Note: Use whatever size you can afford in Windows. This will take space from your hard drive (so make sure it is available to begin with). A Linux server can easily run in 8 GB, but if you plan to run a GUI desktop in addition (the Ubuntu desktop or Kubuntu desktop, for example), you should consider making this between 10 -20 GB. However, because you have chosen the dynamically expanding storage in the preceding step, the virtual machine will automatically expand storage later if you guess wrong here. (I usually just accept 8 GB.)

-> Finish.

Now you will have a new virtual machine. You can create multiple virtual machines, in this fashion. If you desire, you can run each new virtual machine simultaneously (if you have enough RAM and hard drive resources).

Install Ubuntu Server as Guest OS

Other resources

Common issues

Ubuntu 12.04 LTS

Module issues

If you update virtualbox. The modules and the module API may change. Which means you have to compile the modules for your kernel.

If you start an virtual machine in the gui you get a message. That you should run::

  • $ sudo /etc/init.d/vboxdrv setup

But there is no such script. But when you are starting virtualbox via CLI. You get informative message::

  • WARNING: The character device /dev/vboxdrv does not exist.
    • Please install the virtualbox-ose-dkms package and the appropriate headers, most likely linux-headers-generic. You will not be able to start VMs until this problem is fixed.

So you have to install the virtualbox-ose-dkms::

  • $ sudo apt-get install virtualbox-ose-dkms

Then we can see if the vbox module is added::

  • dkms status

Then install it::

  • $ # dkms install virtualbox/<version> $ sudo dkms install virtualbox/4.1.12

If you dont have the kernel headers you will get this error::

  • Error! Your kernel headers for kernel 3.2.0-26-generic cannot be found. Please install the linux-headers-3.2.0-26-generic package, or use the --kernelsourcedir option to tell DKMS where it's located

So you have to install them::

  • $ sudo apt-get install linux-headers-3.2.0-26-generic

Then we have to 'start' the modules::

  • $ sudo /etc/init.d/virtualbox start

Alternatives to Virtualbox

  • Xen is the Ubuntu-supported virtualization platform used for cloud computing. it is the basis for the Amazon EC2 cloud.

  • Another Ubuntu-supported virtualization system is called KVM. It is officially supported, but is somewhat harder to set up for the average user. It also requires hardware virtualisation extensions in your CPU.

  • VMware is a proprietary alternative, with a free virtual machine player available. A free server for Linux can also be found.

  • QEMU is the original virtualization system, on which Virtualbox and KVM are based. It is completely open source and can be used with or without the virtualization hooks found in many new processors.

It is possible to convert virtual machines between these systems (but it is sometimes a time consuming process). A new "open virtualization format" has been created that can be used in several alternative virtual machines 'Open_Virtualization_Format' (Wikipedia) - Wikipedia page on 'Open_Virtualization_Format'.


CategoryVirtualization

VirtualBox (last edited 2012-11-24 11:04:04 by jim-fayettedigital)