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:
- download Virtual Box at Virtual Box official. Just download the latest version suitable for your hardware and operating system.
Step 2. Install Virtual Box
- Start the installer.
- Click next and use the default settings.
- There may be warning windows popping up several times, choose “install”.
Step 3. Create a virtual machine
- Open VirtualBox.
- Create a new Virtual Machine by clicking the New icon (or it will ask you to create a new VM the first time you start up VirtualBox).
Fill in the following information:
- Name: Ubuntu 20.04
- OS type and Version: Linux and Ubuntu (64-bit)
You will then be asked to fill in the “hardware” configuration of the machine:
For memory, the default settings should work fine. You can modify this later.
For hard disk, select “Create a virtual hard drive now”.
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.
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.
- For details, you can read https://askubuntu.com/questions/101715/resizing-virtual-drive/558215#558215. You are advised to not allocate too few space (at least 1GB) for the swap partition as it acts as the virtual memory/page file for the virtual machine.
You will see the Ubuntu 20.04 created on the left column of the list after you have created a VM successfully.
Step 4. Load the installation iso to the virtual machine
- Select ->
- In , , click
- In , click the disk icon , select choose a
- Choose "ubuntu-20.04.1-desktop-amd64.iso" you downloaded before
Step 5. Boot up the VM and start installing Ubuntu
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.
Press the start button. to start the virtual machine for Ubuntu 20.04.
The virtual machine will start up.
Choose Install Ubuntu to install Ubuntu permanently.
- Choose the language preferred and click "Continue".
- Check both boxes in "Other Options" to download updates and install drivers. Then click “Continue”.
- Click “Install Now” and “Continue” with the default options if prompted.
- Type in your username, computer name and password. Then click “Continue”.
Avoid typing long usernames or usernames with symbols. You may need to type this username a lot. Make it as simple as possible!
- Wait and go do something else until the installation is complete .
- Click “Restart Now” when prompted.
- If prompted to remove the installation medium, do this by going to Devices -> Select iso file -> Remove disk from virtual drive.
- You can now login to Ubuntu!
- 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.
- 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.
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.
step 2: If autorun is enabled, you will see the autorun window. Click Run and enter your password to confirm running the installer.
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
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
3. (Important) To link python3 to python command, type
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
4. Install ROS Noetic
Please refer to Lab 5.0 ROS Installation