Creating a basic Ubuntu Virtual Machine
Virtual Box setup
I don’t set up a virtual machine often enough to remember which options I want, or maybe I just have a poor memory. Either way, here are steps to create a simple Ubuntu virtual machine with networking.
Basic Frame
In Oracle VirtualBox, select “New” and answer the prompts as described below.
Name: Suggest “xxx-os-version”. Ex:ample “vb2-ubuntu-16-04-01” or “vm1-ubuntu-16041”

Memory Size: Suggest 8192 MB (8 GB) of RAM, or something less that the host machine has.

Hard disk: create a virtual hard disk now

Hard disk file type: VDI

Disk storage: Dynamically allocated

File location & size: Size by need, and note that Ubuntu needs at least 25 GB. Suggest creating a directory for all things virtual machine and putting the disk file there.

The first time you fire up the virtual machine you will be asked for an operating system file (iso). Download this first and be ready! You can get Ubuntu desktop from http://www.ubuntu.com/download/desktop.
Follow installation instructions. Select download updates while installing ubuntu.

For the hostname, suggest “user-vmX”, then you know by the name what user is defined. Example: “carolyn-vm4”

Guest Extensions
These enable cut and paste between host and virtual machine and folder sharing. See http://virtualboxes.org/doc/installing-guest-additions-on-ubuntu/
Open a terminal window and issue the commands:
sudo apt-get update
sudo apt-get upgrade #(y to prompt or use -y flag; takes a while)
sudo apt-get install build-essential module-assistant #(y to prompt)
sudo m-a prepare
From the running VM window select:
- Devices
- Insert guest additions CD image -
- run
- enter root password
Seup Copy-Paste
From the running VM window select: Devices - Shared Clipboard - Bi-directional
Setup a shared folder
- settings on virtualBox dialog or Devices on current VB window
- shared folders
- add share
- host directory path. ex: C:\Users\COwnby\Documents\VBShare
- name of share, ex: VBShare
- auto mount
- make permanent
- Then from command line: sudo usermod -a -G vboxsf
Nice things to have
Java
Seems that java is required for just about everything. Go ahead and install it now.
sudo apt-get update
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
sudo apt-get install -y oracle-java8-installer
Python
sudo apt install python-pip
Networking
I am running VirtualBox from Windows 10, and setting up networking so my machine is outside accessible has been tricky. This can be done with a bridged adapter or NAT networking
Bridged Adapter
With bridged networking, your virtual machine is seen externally as a normal network device. For more information, see Virtual Box Bridged Networking
Under your VM settings, go to the network tab.
- Attached To: Bridged Adapter

- Name: is the device showing connectivity from Control Panel\Network and Internet\Network Connections

NAT Networking
An alternative is to use NAT Network with port mapping. A port on the host PC is mapped to each virtual machine, so your VM is externally addressable via the host PC’s IP and a port number. For more information, see Virtual Box NAT Networking
You’ll first need to get the ip address of your virtual machine with ip a. Under your virtual machine settings network tab, set:
- Attached To: NAT Network

Then, in Oracle VM VirtualBox Manager
select File - Preferences

- go to Network tab
select the screwdriver

- select “port forwarding”

To enable ssh access, for example, you might set:
- Host Port = 2222
- Guest IP = virtual machine’s IP address from
ip a - Guest Port = 22
Then to ssh to the virtual machine, you use
ssh user@host-ip:2222
Carolyn Ownby BLOG
virtual machine vm