Skip to content

Linux installation

Objectives

At the end of this self-learning lab, you should be able to:

  • use Ubuntu 20.04 inside a virtual machine.

Step 1. Preparation - Download

You can install Ubuntu 20.04 on your own computer without removing the Windows/macOS operating system. It can be done by installing two pieces of software:

  1. Virtual Box

    • download Virtual Box at Virtual Box official. Just download the latest version suitable for your hardware and operating system.
  2. Ubuntu 20.04

Step 2. Install Virtual Box

  1. Start the installer.
  2. Click next and use the default settings.
  3. There may be warning windows popping up several times, choose “install”.

Windows Security Question during installation

Step 3. Create a virtual machine

  1. Open VirtualBox.
  2. Create a new Virtual Machine by clicking the New icon VB_newbutton (or it will ask you to create a new VM the first time you start up VirtualBox).
  3. Fill in the following information:

    • Name: Ubuntu 20.04
    • OS type and Version: Linux and Ubuntu (64-bit) create_harddisk
  4. You will then be asked to fill in the “hardware” configuration of the machine:

create_memorysize

For memory, the default settings should work fine. You can modify this later.

Software layering

For hard disk, select “Create a virtual hard drive now”.

Select filetype during creating hard disk Select storage during creating hard disk

Select file size during creating hard disk

Important

For the size of the virtual hard drive, you are strongly recommended to increase the size instead of using the default settings (we recommend at least 20GB).

  • This setting configures the upper bound on how much storage your virtual machine can use (i.e. the maximum size of the virtual hard disk).

  • As the virtual hard disk is “dynamically allocated”, setting a large disk size will not immediately consume a lot of your physical hard disk space, but instead such space will be allocated automatically when you use more storage in the virtual machine (up till the maximum size configured here).

  • As our development environment (e.g. Ubuntu, IDEs, ROS) consumes a considerable amount of disk space (several GB in total), it is strongly recommended to set a larger value in this step to avoid running into issues of not having enough disk space in subsequent training chapters.

Abstract

There is a way to increase the maximum virtual hard drive size, but it is quite tedious and involves non-destructive formatting of the virtual hard drive.

You will see the Ubuntu 20.04 created on the left column of the list after you have created a VM successfully.

Preface after successfully created

Step 4. Load the installation iso to the virtual machine

  1. Select Settings Setting button -> Storage
  2. In Storage Tree , Under IDE Controller , click Empty

Storage in settings

  1. In Attributes , click the disk icon disk icon, select choose a virtual CD / DVD disk file…
  2. Choose "ubuntu-20.04.1-desktop-amd64.iso" you downloaded before
  3. Click Ok

Step 5. Boot up the VM and start installing Ubuntu

Error

If you are on Windows and you run into errors such as

The installer encountered an error copying files to the hard disk:

[Errno 5] Input/output error

This is often due to a faulty CD/DVD disk or drive, or a faulty hard disk.  
It may help to clean the CD/DVD, to burn the CD/DVD at a lower speed,   
to clean the CD/DVD drive lens (cleaning kits are often available from  
electronics suppliers), to check whether the hard disk is old and in   
need of replacement, or to move the system to a cooler environment.
during Ubuntu installation, then you might have to disable Hyper-V on Windows. Check https://askubuntu.com/questions/1239382/error-when-installing-ubuntu-20-04-in-virtualbox for more information.

  1. Press the start button. Start button to start the virtual machine for Ubuntu 20.04.

  2. The virtual machine will start up.

  3. Choose Install Ubuntu to install Ubuntu permanently.

Select Install Ubuntu

  1. Choose the language preferred and click "Continue".

Select language

  1. Check both boxes in "Other Options" to download updates and install drivers. Then click “Continue”.

Select Install

  1. Click “Install Now” and “Continue” with the default options if prompted.

Select Install type 1.

Select Install type 2 Select Install type 3

  1. Type in your username, computer name and password. Then click “Continue”.

Warning

Avoid typing long usernames or usernames with symbols. You may need to type this username a lot. Make it as simple as possible!

Select Install Ubuntu

  1. Wait and go do something else until the installation is complete 😄.

Select Install Ubuntu

  1. Click “Restart Now” when prompted.

Select Install Ubuntu

  1. If prompted to remove the installation medium, do this by going to Devices -> Select iso file -> Remove disk from virtual drive.

Select Install Ubuntu

Select Install Ubuntu

  1. You can now login to Ubuntu!

Select Install Ubuntu

  1. If you try to reboot, the installation screen may pop up again. To solve this, power off the VM, and remove the iso from the VM storage.

Select Install Ubuntu

  1. You can then start using Ubuntu! Some setting preference windows will pop up and you can select what you preferred. After setting, type Ctrl+Alt+T to launch the terminal.

Select Install Ubuntu

Step 6. Setting and Installing packages

1. You can set the screen size to full screen by using “Install guest additions” in VirtualBox.

step 1: Click Devices > Insert Guest Additions CD image.

Insert CD image

step 2: If autorun is enabled, you will see the autorun window. Click Run and enter your password to confirm running the installer.

Click run Password

step 3: Type Y and press Enter in the appeared console window.

If fail on step 3, close the window, reopen a new terminal and type:

$ sudo apt install virtualbox-guest-utils virtualbox-guest-dkms
Type Y and press Enter in the terminal.

Insert CD image

You can have the full screen now.

2. There are some commonly used packages that have not been installed:

G++: $ sudo apt install g++
Pip3: $ sudo apt install python3-pip
Git: $ sudo apt install git 
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1