This website is preserved for historical and scholarly reference and is no longer actively maintained.
VirtualBox Introduction and Setup
We will use VirtualBox and at least for the first part of
the semester one Virtual Machines. The VM will be Ubuntu
16.04. The following explains how to install a VM on
VirtualBox using the VM distribution release in ISO format.
Before getting started with VirtualBox, please note the following:
- Get familiar with the user's manual
- it is extremely helpful!!
- The computer (probably your laptop) that you will use to
install VirtualBox is referred to as the host operating system
(OS)
- VirtualBox installs the Virtual Machine Manager on your host
OS. This is the software that creates the virtual environment
that is observed by VMs.
- Any VM that we create is called a guest OS
- See the links below to install VirtualBox and also to download
the extension pack. After installing VirtualBox and the VM
you install the extension pack. This provides customized
drivers that run on your host OS (within the VMM) that optimizes
the system to run the specific VM you have installed.
- On Linux or a MAC, you can start VirtualBox by typing
'VirtualBox' in a term.
- We refer to the main VirtualBox user interface program as the
VirtualBox Manager. There are two important configuration panels
- In File, select preferences. This allows global config
options to be set. Global means they apply to all VMs.
- In Machine, select setup. This allows config for one
specific VM to be set.
- There are two methods for installing a VM.
- First, using the VirtualBox program's user interface to
create a new VM. This effectively builds a virtual
computer - but without an OS! The next step is to start
the VM and the process to install an OS should be identical to
if we were installing the guest OS on a bare metal
machine. You need to download the VM's ISO before
creating the VM.
- Second, you can install a VM that is already setup as a
VM. The VM is stored in a file ending in OVA (Open
Virtualization Architecture) or OVF (Open Virtualization
File). These are sometimes referred to as an appliance.
If you are given the VM in OVA format, instead of creating a
VM in VirtualBox's, you would import the VM.
Similarly, you can share your VM by exporting it into a (very
large) OVA file.
Prep for installing our VMs: download the VM
distributions. We will install VM1 using method #1 described
above.
- The rest of this page does not show all steps. But the
the key points are:
- Set each VM to use 2 CPUs (if your Host platform has >1)
- Setup 2 displays
- Setup bidirectional copy/paste buffers
- Make sure to install Guest Additions.
- We will start off using the default network
configuration. After you have installed your Ubuntu VM,
you should have Internet connectivity
- Open a term and issue 'ping 8.8.8.8'
- If you would like to see how we have installed 2 VMs in
past courses, consult this page to configure
the network.
1 VirtualBox Downloads and Documentation
2 Installing a Guest OS on a VirtualBox VM
Step 1. Install VirtualBox on your Host OS.
Step 2. Create a VM
- Start the virtual box program on your Host OS
- In the VM VirtualBox Manager, select NEW and follow the steps
to create a new VM. You need to know what type of Guest OS -
Windows, freeBSD, Kali, Ubuntu ... and also if you want 32 or 64
bit Guest OSs.
- Increase memory size to 2Gbytes, tell it to create a
virtual drive NOW, a disk space of 20 GBytes (10 GBytes is
probably ok), select all the defaults (dynamic allocation,
VM file type VDI).
Step 3. Install a Guest OS
- For a Ubuntu VM, download the latest 64 bit LTS version from here
- Please use the 64-bit version.
- The file you download should be an iso file- you can
keep this file in the Downloads directory (or where ever you
downloaded it).
You do NOT need to burn an install CD.
- Install Linux by double clicking the new VM (VM1). It will
then ask for a startup disk - point it to the ISO file you
downloaded. Then follow the defaults throughout the Linux OS
installation.
Step 4. Install the "Guest Additions" - which adds optimized
drivers to your Linux installation.
- Start your VM and select the 'Devices' option and then
'Insert Guest Options CD' - it should ask you if you want the
VM to run the install program - say yes.
- An alternative, in a Ubuntu guest, issue 'sudo apt-get
install virtualbox-guest-utils' and
- Note cd to the mnt of the CD image, Issue 'sudo
runasroot.sh' or 'sudo ./VboxLinuxAdditions.run' or
'sudo VboxLinuxAdditions-amd64.exe'
- See this page for help: https://www.virtualbox.org/manual/ch04.html
Step 4. Tweak your VM settings to enable these useful features::
- Make sure VM Manager is configured for CPU acceleration. Make
sure your VM is not running, from VirtualBox Mgt, select
Settings, and then System, and then Acceleration and Enable.
- If this is not selectable, then you should reboot your
computer, and go to BIOS setup to enable VM Acceleration.
- To allow the VM to operate on >1 physical CPUs
- VM Virtual Box Manager, select Settings and then System
and set number of processors
- To make it easy to transfer files between VMs and Host OS, I
create a Shared Folder
- On your VM, select Devices and Shared Folder.
- Make sure to create a folder on your Host OS first, and
then specify this as the shared folder. Indicate it is
permanent.
- On your VMs, issue a 'df -k' and you should see the
folder mounted. Note that you might need to use sudo to
access the folder.
- To allow cut and paste across your Host and Guests, enable
Bidirectional Drag and Drop in each VMs Settings, Select
General, and then Advanced - set shared Clipboard and DragNDrop
to bidirectional. .
- This is an example .bashrc for Ubuntu 16.04 that provides some
helpful alias's and functions : ./bashrc
Step 5. Packages to install after a installing a Ubuntu VM
After a fresh install of Ubuntu, you should do a 'sudo apt
update'. Then issue 'sudo apt-get install xxx' the following (note
that some of these might already be on your system).. To see all
installed, 'apt-cache pkgnames', To see if a specific pkg is
installed, like iperf, 'apt-cache showpkg iperf', And if you know
the program you want to get but it is different from the package
name, you can try 'apt-cache showpkg iperf'.
- build-essential
- git-core
- vim
- wget
- curl
- bc
- inetutils-traceroute
- tcptrace
- dhcping
- xutils-dev
- iperf
- sysstat (to get mpstat)
- dos2unix
- source-highlight (to get check-regexp)
- snmp
- openssh-server - need to install and start to ssh into your VM
- sudo systemctl restart sshd.service
The following are optionally
- To build programs that use the pcap libaray:
- sudo apt-get install libpcap-dev
- Xplot is a very useful plotting program
- sudo apt-get install xplot
- To get useful packet trace analysis tools
- wireshark-common (capinfos is very helpful)
- tcptrace (can generate useful summary + plots of tcp cxs)
- Octave is an open source system similar to matlab.
- Full install:
- sudo apt-get install octave
- If it was not in the main repos, you could setup the ppa.
- sudo apt-add-repository ppa:octave/stable
- sudo apt-get update
- sudo apt-get install octave
Step 6 Setup Networking on the VM
When installing just one VM, the default networking that is setup
by VirtualBox is sufficient. It allows the VM to reach the
Internet - but it does not allow any Hosts from an outside network
to reach the VM (unless the VM initiates the connection).
Refer to this page
for further information on network options.
Step 7 Additional setup through the command line interface
After virtualBox is installed, a set of helpful command line
programs are available on your Host OS. On a Windows Host OS,
these programs are located in C:\Program Files\Oracle\VirtualBox.
The main command line interface program is vboxmanage. I usually
add the path to my User Path environment (on Windows, Control
Panel, System, Advanced Settings and then Environment Variables).
Try 'VboxManage' for a list of all command options.
VboxManage list vms ; lists the names of your VMs.
VboxManage showvminfo VM1 ;shows all info for the VM named VM1
You can configure more properties and aspects of each VM through
the command line interface. Refer to the Users Manual for details.
Misc information
- To switch in and out of full screen, the default key sequence
is CNT-F
- Once operational, we will refer to the different screens as
follows:
- the main VirtualBox window that allows you to start/stop
and configure the VMs, will be referred to as VirtualBox
Manager, sometimes referred to as Mgr Window.
- The window that represents the VM (the specific VM name is
in the top portion of the window). We refer to this by a
specific VM name, such as VM1Window or sometimes as VM1.
- System wide configuration is done in the VirtualBox
Manager by selecting File and then Preferences. You can also
reach this configuration window from a VM Window. We refer
to this configuration window as System Config Window. For
example, the Network Preference allows specific types of
virtual networks to be created ... and in some cases further
VM configuration is required.
- VM configuration is found in several ways:
- From the Mgr Window, highlight the VM listed in the
set of VMs that have been configured, then select
Settings (or Machine).
- From a VM Window, select Machine and then Settings.
- A VirtualBox VM consists of three pieces:
- one or more hard disk images (VDI files),
- zero or more snapshots (VDI files)
- xml config files.
Snapshots, clones, and export/import
Three very useful capabilities provided by most VMM systems
are snapshots, clones, and export/imports.
- Snapshots are highly recommended- it is a way to fall back to
a recent, working instance of your VM. While it
might not happen frequently, you are likely to encounter some
sort of failure that might prevent your VM from booting ever
again (or .... it might require significant effort to restore
the corrupted system).
- A snapshot is equivalent to a backup of your system
- Porting a VM snapshot to another machine allows you to create
a customized VM, and then publishing it making it available to
others.
- To publish your VM, simple right click the VM in the
VMMManager and select clone.
- A clone is an exact copy of a VM, so after doing it you have
two virtual machines on your host, identical except for the
things that have to be different such as the UUIDs. If you are
developing a system this allows you to fork it, restore to a
former state, etc, or easily to put together a virtual
network of originally-identical machines. Because of the
UUIDs, in particular, you need to do this rather than just
make a file-copy of the VM directory.
- Export/Import an appliance
- An appliance is a complete VM (or indeed several of them)
compressed and packaged into a single file. The idea is that
you can then pass this single file (on a memory stick or XHD,
say) to someone else using a different physical machine. They
can then easily import your system to theirs, and they do not
need to do anything else to get it going. It is virtual
machine(s) packed into an archive for easy distribution to
others.
A clone is really designed for use on the same host, an
appliance for copying to a different one.
last updated: 8/27/2019