Skip to content

Linux Installation

Objectives

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

  • use Ubuntu 24.04 inside a virtual machine.

What is Linux?

  • Linux is an operating system (OS) like Windows and MacOS, which is the layer that runs all user applications and coordinates hardware like CPU and memory.
  • There are many different distributions of Linux, and Ubuntu is one of them. In M2 (as of 2024-present), we use Ubuntu 24.04 (Noble Numbat), and you are strongly recommended to use the same version.

Installation

Step 1. Preparation - Download

Download Docker on your local machine, select the correct installer and click download from here.

Step 2. Launch Docker Desktop

Find your Docker Desktop application and launch it. The docker daemon will start running at the background.

Step 3. Pull Ubuntu 24.04 Image and Run

Open a terminal and run the following commands:

  1. Pull the Ubuntu 24.04 image with ROS 2 pre-installed. The image we use is this.

    $ docker pull tiryoh/ros2-desktop-vnc:jazzy
    
  2. Create a container from the pulled image and run it using following command. Here we set the container's name as ros2, you can freely use other names. Upon successful running, you can see output of your terminal similar to the below.

    $ docker run --name ros2 -p 6080:80 --security-opt seccomp=unconfined --shm-size=512m -v $HOME/.ssh:/home/ubuntu/.ssh tiryoh/ros2-desktop-vnc:jazzy
    
    ...(omitted)
    2024-09-19 03:01:14,380 INFO supervisord started with pid 38
    2024-09-19 03:01:15,383 INFO spawned: 'novnc' with pid 39
    2024-09-19 03:01:15,386 INFO spawned: 'vnc' with pid 40
    2024-09-19 03:01:16,787 INFO success: novnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
    2024-09-19 03:01:16,788 INFO success: vnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
    

Step 4. Acesss Ubuntu GUI and Play

  1. Access Ubuntu GUI with your browser. Open a tab in your browser, and go to http://localhost:6080/. You can see the noVNC icon show up, and you can press "Connect" to get into the Ubuntu desktop.

  2. Inside your Ubuntu GUI, open a terminal by clicking Terminator app on the left. You can run any commands and GUI application from here.

Step 5. Stop Docker Container

If you finish playing with Ubuntu, you may want to stop the container. Replace <container_name> with your container's name, e.g. ros2.

$ docker stop <container_name>

Step 6. Start An Existing Container

The container we created above won't disappear after we stop it. When next time you want to play with this container, you can directly start it without creating a new container. Run the following command, and replace the <container_name> with your container's name, e.g. ros2.

$ docker start -ia <container_name>

Step 1. Preparation - Download

You can install Ubuntu 24.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 24.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 24.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 24.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-24.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 24.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 :smile:.

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