VirtualBox running Ubuntu

Status

As of May 18, 2016 the Ubuntu 16.04 MATE installation described within for VirtualBox 5.0.20 works on Windows, but not on the MAC OSX (10.11.5). I have tried Desktop versions of Ubuntu, Ubuntu MATE and Lubuntu and the graphical installer consistently chokes.

I was, however, successful with the Lubuntu alternative distribution (with a non-graphical installer). Go to
http://cdimage.ubuntu.com/lubuntu/releases/16.04/release/
and download:
lubuntu-16.04-alternate-amd64.iso  
Once you have this installed, you can then install and use MATE Desktop by:
$ sudo apt-get install mate-desktop-environment
You won't get everything from an Ubuntu MATE installation, but you'll get the essential features.

Description

When working with virtual machines, the machine in which VirtualBox or other virtualization software is installed is called the host. The virtual machine supported within this virtualization software is called the guest. The document assumes that the host machine is either Windows or MacOSX and the guest is Ubuntu. You should have at least 4GB of RAM on your system. The Ubuntu guests work well when given 1GB of RAM.

For sake of definiteness, I will assume VirtualBox 5.0.20 and Ubuntu MATE Desktop 16.04, 64-bit. The Ubuntu Desktop variant is up to you, you just have to adapt my Ubuntu notes to the Desktop version you choose.

Enable Virtualization in the BIOS

In order to use "full" virtualization on Windows computers, it may be necessary to enable it in the BIOS. The exact details are different for every system, but you have to reboot the machine and Enter Setup. Move through the tabs looking for something like:
Virtualization Technology
If it indicates Disabled, then you have to change it to Enabled. Once done, Save and Exit the Setup.

Basic Installation

Download the platform-dependent version of VirtualBox from the VirtualBox site and install it. When you start it up, it should present the option to download and install the VirtualBox 5.0.20 Oracle VM VirtualBox Extension Pack. Follow through the installation of this.

Download the ISO installation file, ubuntu-mate-16.04-desktop-amd64.iso, from the Ubuntu MATE site. Move this ISO file where you want to maintain a collection of this and other ISO files.

Create the VM

  1. Click New. You are presented with a dialog to set basic guest OS features. The installation docs recommend no less than 512MB for a Desktop installation. Make these changes:
    Name and operating system
      Name: VMNAME
        Type: Linux
    Version: Ubuntu (64-bit)
    Memory size
    Version: 1024 MB
    Click Create.
  2. Next, you are presented with a dialog to set the virtual disk size. By default it is dynamically allocated, so it doesn't cost much to make it big. Perhaps something like.
    Version: 100 GB
    Click Create.

The Guest Installation

The machine VMNAME should be selected in the virtual machine list. Click Start.
  1. Installation Media

    Click on the file selection button on the right of the selection list and navigate to the ISO file, ubuntu-mate-16.04-desktop-amd64.iso. Choosing the file should make it appear as the chosen selection in the list.

    Click Start.
  2. The boot process should take you to a choice of popups: Try Ubunutu MATE or Install Ubuntu MATE. Choose Install.
  3. Preparing to install Ubuntu MATE. Check both checkboxes:
    Download updates whitle installing Ubuntu MATE
    Install third-party software for graphics and Wi-Fi hardware, Flash, MP3 and other media
    Click Continue.
  4. Installation Type. Make the choice which represents erasing the entire disk and installing Ubuntu.
    Erase disk and install MATE
    Press Install Now and Continue at the popup.
  5. Where are you? Probably the default. For us New York. Press Continue.
  6. Keyboard Layout. Take the default. Press Continue.
  7. Who Are You? This provides you with a login as a non-root administrative user:
    Your name: your full name (whatever you want)
    Your computer's name: VMNAME
    Replace VMNAME by the machine name given to you.
    Ignore any message: "That name already exists on the network."
    Pick a user name: VMLOGIN
    Replace VMLOGIN by a suitable non-root account name on your machine.
    Choose a password: A password known only to you.
    Confirm your password: Re-type it.
    Keep the other default settings. Press Continue to finish the information Ubuntu needs.
  8. Welcome to Ubuntu MATE. Wait for the installation to complete and watch the ads go by; the whole process is very short. At the end click the Restart Now button. Press ENTER to confirm reboot and remove the Flash drive.

Adjust Guest Settings Guest

When the reboot is done, log in and shut down the guest machine. We want to adjust some settings in VirtualBox before proceeding.
  1. Click the Settings button for the VMNAME virtual machine.
  2. In the Display tab, set the Video Memory to the max (128MB). Then check the boxes:
    HiDPI Support: Use Unscaled HiDPI Output Acceleration: Enable 3D Acceleration
  3. In the General ⇾ Advanced tab, set
    Shared Clipboard:
    Setting a shared clipboard allows you to copy in the host and paste into the guest, or vice versa. On a MAC, you just have to remember that the guest uses control and host uses command.
  4. In the Shared Folders tab, locate and click the Add new shared folder icon on the right. Decide on a folder on the host which you want to share with the guest, say your Documents folder. Then set:
    Folder Path:   /PATH/TO/Documents
    Folder Name: Documents
    Folder Name: Read Only
    Folder Name: Auto-mount
    The Folder Name is what appears in the guest machine. It can be anything you want.
  5. Click OK to leave the Settings dialog.

Install Guest Additions

It is absolutely necessary that you do this step. Start your guest machine. The required package installation is:
$ sudo apt-get install build-essential
From the VirtualBox menu select:
Devices ⇾ Install Guest Additions
When you log in to Ubuntu, you will see the VBOXADDITIONS_version CD icon on your desktop which indicates that this "CD" is mounted. You may be able to do everything by point and click, but this shell-based method always works:
  1. Open a terminal shell.
  2. Navigate to the mounted directory (use tab completion!):
    $ cd /media/VMLOGIN/VBOXADDITIONS_version
    
  3. Then run the guest additions installer:
    $ sudo ./VBoxLinuxAdditions.run
    
After completing this successfully, Reboot the machine. When you come back and log in, you should see the shared folder appear on the Desktop:
sf_SharedFolderName
To permit access to this shared folder, you have to add yourself to the vboxsf group like this:
$ sudo adduser VMLOGIN vboxsf
You have to log out and log back in for this to take effect.

Upon logging in, open the shared folder to reveal the documents on the host side.

Subsequent Guest Addition Installations

If you update VirtualBox and possibly update the Ubuntu kernel you need to reinstall the Guest additions:
$ cd /media/VMLOGIN/VBOXADDITIONS_version
$ sudo ./VBoxLinuxAdditions.run
$ sudo reboot
You'll often get a visual cue of this need if the window doesn't resize or the shared folder doesn't appear.

Network connection between host & guest

This section is not absolutely necessary, but it is great if you want to access on the host services running on the guest, and/or vice-versa.

Adjust Settings for Virtual Machine

Power down the guest machine. Edit VirtualBox's Preferences (not Settings). Go to the Network tab and look for a listing of
Host-only Networks:
   vboxnet0
If you do not see this, click the "+" button on the side to add it.

Now create the Host-only Adapter network adapter:
  1. Click the Settings button for the VMNAME virtual machine.
  2. In the Network tab, click on Adapter 2, check Enable Network Adapter and select Host-only Adapter in the Attached to selection list.
  3. Click OK to leave the Settings dialog.
Start up the virtual machine.

Confirm the vboxnet0 network address

On your host machine, open a terminal shell and run either ifconfig (Mac) or ipconfig (Windows) and look for the interface:
VirtualBox Host-Only Network
Hopefully, the IP4 information associated with this is
address: 192.168.56.1
netmask: 255.255.255.0  or  ffffff00

Confirm the DNS IP address on the guest

Go into your Ubuntu guest machine. It is likely that the new network has already been set up on eth1 via DNS. Open a terminal and type:
$ ifconfig
...
enp0s8   Link encap:Ethernet  HWaddr .....
         inet addr:192.168.56.LAST  Bcast:192.168.56.255  Mask:255.255.255.0
         ...
For the most part, this DHCP-generated IP address is unlikely to change.

Test network connectivity between host and guest

Refer to the DHCP-generated IP address above as
GUESTIP
From the host machine check:
$ ping GUESTIP
Open a shell in the guest (Ubuntu) machine and check:
$ ping 192.168.56.1

Set a static IP address on the guest (optional)

If you're so inclined, you can set a static IP address for this guest. You will need to access the system's Network Manager, wherever it to be found. The network configuration steps should look something like this:
  1. You will have two connections. Examine the Ethernet tab of both to find out which one corresponds to the network interface enp0s8. Choose that one.
  2. Select the IP4 Settings tab.
  3. Change Method to Manual.
  4. Click the Add button below to add a new Address.
  5. Enter the Address: 192.168.56.10. The first 3 octets must match the vboxnet0 IP address and the last octet must be anything other than 1, probably less than 100.
  6. Click on the adjacent NetMask box and enter 24 (it might automatically enter it for you)
  7. Enter in the Gateway: 192.168.56.1 (the vboxnet0 IP)
  8. Click in the blank area of the DNS Servers and also enter 192.168.56.1
  9. Click Save (authenticate with your password)
  10. Click Close to leave.
Restart the VM guest.

Fix the routing (if necessary)

When you boot up and come back in check if the routing is working by:
$ ping 8.8.8.8
If this doesn't work it means that the static IP just set has become the default route, which is not what you want. To be correct you should see:
$ route
Destination     Gateway    ...
default         10.0.2.2   ...
Here's the fix. Create the file (as root):

/etc/network/if-up.d/gwconfig
#!/bin/sh
 
if [ "$IFACE" = "enp0s8" ]; then
 route delete default gw 192.168.56.1
fi
select
Make it executable and reboot
$ sudo chmod +x /etc/network/if-up.d/gwconfig 
$ sudo reboot


© Robert M. Kline