Operating system virtualization with VirtualBox

VirtualBox allows you to install one or more operating systems in virtual machines (VMs) on your computer without affecting your original bootloader or disk partitions. It has many uses; here I describe using it for trying new distributions without putting my production system at risk.

On a Linux host
Using your package manager, install at least virtualbox. I also install:

  • Guest additions, which add useful features such as file sharing between host and guest. Different distributions may give it different names. For example, openSUSE calls it virtualbox-guest-tools. My own experience is that installing them at this stage does nothing and that I always have to download them direct from Oracle later.
  • DKMS, which handles kernel modules, sparing you the task of recompiling.
  • Distribution-specific packages. For example, openSUSE 12.3 offered by default to install vboxgtk, a third party GTK frontend to VirtualBox. I deselected it and installed instead virtualbox-qt, the native frontend. OpenSUSE 13.1 offered by default to install virtualbox-qt, which I accepted.

If your package manager does not carry VirtualBox, you can download and install binaries from the project’s download page.

I add my user to the newly created vboxusers group, then log out of the host operating system and log back in. This allows my user access to the USB subsystem on virtual machines.

On a Windows host
Download VirtualBox from the project’s download page and install it in the usual manner. I also install all optional features.

Open VirtualBox’s graphical user interface. Where on Linux’s user menu it is found depends on your distribution, desktop environment, and perhaps which optional frontend you’ve chosen. Examples I’ve seen:

  • Mageia 2, Xfce 4: Tools – Emulators – VirtualBox
  • openSUSE 12.3, Xfce 4, virtualboxqt: System – Oracle VM VirtualBox

Press “New” to create a new virtual machine. Follow the on-screen instructions; refer to the user manual if needed. I choose:

  • VM Name – Name: As appropriate.
  • VM Name – OS Type – OS: As appropriate.
  • VM Name – OS Type – Version: As appropriate. If your exact version or distribution isn’t listed, select the most similar option.
  • Memory – Base Memory: As appropriate. For testing a Linux distribution, I find 1024 MB to be adequate.
  • Virtual Hard Disk: Create a new hard disk (default).
  • Virtual Disk Creation – File Type: VDI (default).
  • Virtual Disk Storage Details: Dynamically allocated (default). I am now testing the alternative, a fixed size virtual disk, which is said to provide better performance. For testing a moderately sized Linux application, 15 GB should be more than adequate.
  • Virtual Disk File Location and Size – Location: The default location is usually appropriate.
  • Virtual Disk File Location and Size – Size: As appropriate. For testing a Linux distribution, I find the default of 8 GB to be adequate.

It’s not necessary, but once a virtual machine is created I like to open the settings (Machine – Settings) and further adjust things. Settings that work well for testing a distribution’s performance are:

  • General – Advanced – Shared Clipboard: Bidirectional.
  • System – Motherboard – Base memory: As much as you can get without going “into the red”, which would generate a warning that the host OS may choke. How much you can get depends on how much physical memory the host hardware has. You already know this, but it bears repeating: virtualization works best with lots of memory.
  • System – Motherboard – Extended Features – IO APIC: Enable. TODO: Link to a discussion of why.
  • System – Processor – Processors: Take the lesser of how many processors or cores the guest OS can handle or that the host hardware has. If your host system does not have hardware virtualization support, you are stuck with one processor.
  • System – Processor – Execution cap: 95%, just so your host has a few cycles of its own even if the guest goes crazy.
  • Shared Folders: TODO: Document what to do.

Now that a virtual machine has been created and tweaked, start it. The first run wizard will start; follow the instructions. In “Select Installation Media”, navigate to the physical disk or the ISO image file of the distribution you wish to install in your new VM and select it. Then install and use your new OS as you normally would.

Installing guest additions is optional but recommended: they add useful features such as file sharing between host and guest. See “Install Guest Additions for a better VirtualBox experience” for instructions.

64 bit guest support
VirtualBox supports 64-bit guest operating systems if certain conditions are met, including having a 64-bit processor with hardware virtualization support. Most processors these days meet this modest criterion, but my museum piece does not. It is 64 bits but doesn’t support hardware virtualization, so although I have a 64 bit host I can only run 32 bit guests.

Network card drivers not testable
VirtualBox incorporates a lot of smarts to get you up and productive quickly. This is usually a good thing, but it won’t help you if you want to see if a particular distribution support the hardware’s network card: VirtualBox will seamlessly use the host OS’s drivers.

On Linux, VirtualBox’s configuration files are in ~/.VirtualBox/, and virtual machines are in ~/VirtualBox VMs/. I use VirtualBox for testing purposes and don’t need to back up anything, so I exclude both directories from my backup set.

On Linux when installed via your package manager, VirtualBox should be kept up to date by your distro’s normal methods.

I like VirtualBox, but there are alternatives.

When considering alternatives to VirtualBox, keep in mind the distinction between the two types of hypervisors. Type 1 hypervisors run directly on bare metal hardware. Examples include Xen, KVM, and Hyper-V. Type 2 hypervisors such as VirtualBox run atop a host operating system. So when you go shopping for alternatives, be careful to compare apples to apples.

Install Guest Additions for a better VirtualBox experience. Also see the 1st paragraph of this article for more references.
VirtualBox project site
VirtualBox end user documentation
Best practices for resource overprovisioning gives different recommendations for settings than I do, and I suspect he’s got it right.

These notes refer to VirtualBox 4.2 on openSUSE 13.1 and were last updated on 7 July 2015.


About Warren Post

So far: Customer support guy, jungle guide, IT consultant, beach bum, entrepreneur, teacher, diplomat, over-enthusiastic cyclist. Tomorrow: who knows?
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

2 Responses to Operating system virtualization with VirtualBox

  1. Pingback: Installation notes, Linux Mint Debian 201204 | A maze of twisty little passages

  2. Pingback: Planning partitions and filesystems | A maze of twisty little passages

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s