VirtualBox with Ubuntu MATE

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.

For sake of definiteness, I will assume VirtualBox 5.2.x and Ubuntu MATE Desktop 18.04, 64-bit:
ubuntu-mate-18.04-desktop-amd64.iso 

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.2.x Oracle VM VirtualBox Extension Pack. Follow through the installation of this.

Download the ISO installation file, ubuntu-mate-18.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. Assuming you have 8GB of RAM and can spare 2GB for this VM. Make these changes:
    Name and operating system
      Name: VMNAME
        Type: Linux
    Version: Ubuntu (64-bit)
    Memory size
    Version: 2048 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-18.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. Keyboard Layout. Choose Continue.
  4. Updates and Other Software. Choose:
    Normal Installation.
    Download updates whitle installing Ubuntu MATE
    Install third-party software for graphics and Wi-Fi hardware, and additional media formats
    Click Continue.
  5. 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.
  6. Where are you? Probably the default. For us New York. 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

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 install build-essential
From the VirtualBox menu select:
Devices ⇾ Install Guest Additions
You'll see this choice selected:
Open Autorun Prompt
Click: OK

Click: Run, and enter your password.

Click Enter to stop the terminal actions. Then Restart the VM.

After you log in the view is resizable.

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.

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

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:
$ sudo apt install net-tools
$ 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. Most likely the one you want is "Wired Connection 2". To be sure, examine the value found in the Ethernet tab of the network interface and correspond this to the value found of "ether" found in the ipconfig information of the terminal output.
  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 Save (authenticate with your password)
  9. 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
/sbin/ip route del default via 192.168.56.1
select
Make it executable and reboot
$ sudo chmod +x /etc/network/if-up.d/gwconfig 
Reboot the VM guest to have check.


© Robert M. Kline