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.
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”
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:
- Insert guest additions CD image
- enter root password
From the running VM window select: Devices - Shared Clipboard - Bi-directional
Setup a shared folder
- Select settings on virtualBox dialog or Devices on current VB window.
- Select shared folders from the left pane.
- Add a share by selecting the folder with plus sign icon on the right.
- On the Edit Share dialog:
- Folder Path is a host directory path; ex: “C:\Users\COwnby\Documents\VBShare”.
- Folder Name is the name of the share on the VM, ex: “VBShare”.
- Check boxes for auto mount and make permanent
- Select OK.
- Select OK to close the settings dialog.
- Then from command line issue the command
sudo usermod -a -G vboxsf <username>
Restart the virtual machine.
Nice things to have
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
sudo apt install python-pip
Follow instructions from the Docker store
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
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
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
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
- Guest Port = 22
Then to ssh to the virtual machine, you use