From charlesreid1

VirtualBox is a handy piece of software that creates a virtual computer - that is, an environment in which an operating system is "tricked" into thinking it is running on an actual physical computer, but in reality is simply a piece of software (running on top of another operating system).

So, why VirtualBox, instead of VMWare, or Parallels, or Boot Camp?

  • It's free AND open-source
  • It's supported by a company (Oracle), making it unlikely to whither up or go away
  • It doesn't require its own partition, because it stores the hard drive for each operating system in one single file (.dvi format) (this makes it easy to back up and share virtual machines)

Notes

Installing an OS

Easiest way to install an operating system is not to manually install it - use osboxes.org. They have many clean installs of operating systems provided as virtual box images.

Networking


VirtualBox Directory Structure

Before starting the VirtualBox guide, I will explain the layout of my VirtualBox directory.

I create a directory, e.g. ~/vbox, in which I keep all VirtualBox-related files. This directory is set up as follows:

  • ~/vbox - the VirtualBox folder
    • ~/vbox/HardDrives - contains the virtual hard drive
    • ~/vbox/Media - contains CD/DVD/disk images mounted by virtual machines
    • ~/vbox/Shared - a folder that is shared between the virtual machine and the real machine


Old Notes

Downloading and Installing

A binary VirtualBox installer can be downloaded for almost any operating system, from http://www.virtualbox.org/wiki/Downloads. The installation process is typical, (requires administrative privileges on a Mac). When you're done installing it, and you run it, you'll see an empty list - there are no virtual machines.

Creating a Virtual Computer

To create a virtual hard disk in the location of your choice, click the folder icon.

To create a virtual computer, click "New". This starts a wizard that guides you through the process.

  1. Select a name for the virtual machine, and a corresponding operating system type.
  2. Select an amount of memory for the virtual machine.
  3. Create a virtual hard drive for the machine. You should probably pick "Dynamically expanding sotrage". This will create a file that starts at size 0 and grows as the virtual computer's usage grows, until it hits the maximum file size (the final selected size of the hard drive). You can select the location of the virtual hard disk, e.g. ~/vbox/HardDrives.
  4. Confirm that all the details are as you wish.

Installing an Operating System

Think of creating a virtual computer as going to the store and buying a bunch of hardware to assemble a computer. When you do that, you have to install an operating system. Meaning, if you're installing an operating system that requires a license, like Windows, then you MUST have a license!

To install an operating system, you need some kind of media (a CD or DVD image, .iso format - for example, from http://www.ubuntu.com/desktop/get-ubuntu/download), and some way for the virtual computer to know about it (so it can mount it). You will see the virtual computer you created in the list when you open the VirtualBox program. If you select the machine, you can click "Settings" to modify some of the settings of the virtual machine. Click the "Storage" icon, and you'll see the hard drive (.vdi file) you created under the "IDE Controller" list.

The "Storage" options for a virtual computer.

There are a number of different things one can do from this window. First, when you pick "IDE Controller", you will see two icons: one is a CD with a green plus sign, and the other is a disk drum with a green plus sign. The former will allow you to add a CD or DVD drive to the virtual computer (if this were a physical computer, this would be equivalent to adding an additional physical CD or DVD drive). The latter will allow you to add an additional hard drive (again, this is equivalent to physically installing a second drive).

Editing the CD/DVD attributes.

You need to add a CD/DVD drive, which is created as empty, and then point it to a CD/DVD image. When you select the empty CD/DVD drive, you can pick a CD/DVD image to mount using that drive. Click the folder icon next to the drop-down menu that says "Empty", and navigate to ~/vbox/Media (or wherever you put the CD/DVD image). Pick the .iso file you want to mount.

Once you have selected the .iso file, the CD/DVD drive will mount that .iso file whenever you start up the virtual computer. If you are done installing the operating system, and no longer need to mount that image, go back to the "Storage" settings and pick "Empty" from the drop-down box.

Finally, you're ready to start up your virtual machine. Select the virtual machine and press "Start". You will see a small window open, in which the boot sequence for your virtual machine will take place. The installer for your operating system should begin.

Installing Guest Additions

The Guest Additions are a set of features that can be installed on the virtual machine. The most useful features include:

  • the ability to arbitrarily resize the virtual machine's window
  • a shared folder (a location in your host operating system that is also seen by the virtual operating system, allowing one to pass files between the two)
  • mouse pointer integration (meaning that when you move the mouse pointer over the virtual machine's window, mouse movement will automatically be used by the virtual machine, rather than having to click inside the window to use the mouse pointer)

To install the guest additions, start up the virtual machine, and click Devices > Install Guest Additions. This will mount a CD drive in the virtual (guest) operating system. You will see a binary (.exe for Windows, and an executable binary file for *nix systems) in the CD drive. Run it to start the installation process. Once you're done, you should restart the machine. You can now utilize the new guest addition features.