This website is preserved for historical and scholarly reference and is no longer actively maintained.
VirtualBox Introduction and Setup
Last update: 8/30/2021
This page highlights installing a VM using VirtualBox. This
page is likely to expand and change as it is used to support
multiple classes. Some classes will install a single VM
(VM1, Ubuntu 18.04 or 20.04) and other classes will
install two VMs, VM1 (Ubuntu) and a Kali
VM. The former will be called either VM1 or Ubuntu-VM.
The latter will be called either VM2 or Kali-VM.
See Section 2 for importing a VM appliance. See
Section 3 for installing a VM 'the long way' - you
will need a ISO file holding the OS you wish to run in your VM.
Before getting started with VirtualBox, please note the
following:
- First, make sure to get familiar with VirtualBox
- This page on definitions is very
helpful - please read about
extension pack and installing 'guest
additions'.
- To verify you have installed the Extensions, in the
VirtualBox Manager, select file, select
preferences, select Extensions. On the right it should
identify the version of the 'Oracle VM VirtualBox Extension
Pack' (or it will be blank).
- To verify if Guest Additions are installed on a Linux VM
such as a Ubuntu 18.04 guest OS, from a term on the VM
issue 'lsmod | grep -i vbox' . If you see items
listed such as vboxpci or other vbox* items, Guest Additions
have been installed.
- 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 computer
that is used by the VM.
- Any VM that we create is called a guest OS
- Make sure you understand the difference between the
VirtualBox Extension pack and Guest Additions.
- After installing VirtualBox, the process usually prompts
to download and install the extension pack. This
provides customized drivers that run on your host OS (within
the VMM) that optimizes the system to run VMs on the Host
OS.
- Guest Additions: After your VM is installed and
running, you might be prompted to install the Guest
Additions. This is Guest OS specific, providing device
drivers that operate much more efficiently than the standard
hardware abstraction drivers.
- On Linux or a MAC, you can start VirtualBox by typing
'VirtualBox' in a term.
- We refer to the main VirtualBox program as the VBox
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.
- Long Method: create a virtual computer and install
the Guest OS (with an ISO file).
- Shorter Method: Import a VM appliance. The VM
is stored in a file ending in OVA (Open Virtualization
Architecture) or OVF (Open Virtualization File). These
are sometimes referred to as VM appliance. If you are
given a VM in OVA format, instead of creating a new VM in
VirtualBox, you import the VM through the 'File' and
'Import Appliance' options.. Note that at any point
you can create an Appliance based on the state of your VM.
A similar concept allows you to take a 'snapshot' of
your VM. This is like a backup - it gives you something that
was working you can go back to.
1 VirtualBox Downloads and Documentation
2 Importing a VM Appliance
Step 1. Download the OVA file to your computer
Step 2. From Vbox Manager, select File and then select
Import
Step 3. After the OVA file is imported your should see the
new VM in the VBOx Manager's list. Select the VM and
then Start
Step 4. You should see the guest OS boot. The
default network is called 'NAT'. Open a
terminal, issue an 'ip link' or 'ifconfig' - you
should see two interfaces. The lo is the 'loopback'
interface. Depending on your system, the name of the virtual
ethernet is something similar to enp0s3. Try 'ping
localhost' and then 'ping 8.8.8.8' - the former pings
the localhost and the latter pings a google DNS server.
3 Installing a Guest OS on a VirtualBox VM by installing
a guest OS ISO file
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 5 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 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.
4 Misc Info
- 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.
5 Final Touches
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
Virtual Box FAQ
As we continue to experience and debug VM related problems we
will post the questions/answers below
Problem: A Ubuntu 18.04 VM does not size correctly on your
host OS (i.e., your laptop).
Answer: There are other similar problems and many
possible fixes. Here are some things to try:
- In the Display configuration in the VM's Machine
Settings, reduce the scale factor.
- In the Display configuration in the VM's Machine
Settings, specify a graphics controller of VMSVGA and/or
disable 3D acceleration.
- If you are using a second display, try to size the VM first on
your laptop's display.
Problem: On a Ubuntu VM, what are the best terminal profile
settings ?
Answer: Try a color combination of black text on a
white background.