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:
-
Pull the Ubuntu 24.04 image with ROS 2 pre-installed. The image we use is this.
$ docker pull tiryoh/ros2-desktop-vnc:jazzy
-
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
-
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. -
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:
-
Virtual Box
- download Virtual Box at Virtual Box official. Just download the latest version suitable for your hardware and operating system.
-
Ubuntu 24.04
- You can download Ubuntu at 24.04 release.
- In most cases, you will want to install the 64-bit PC (AMD64) desktop image "ubuntu-24.04.1-desktop-amd64.iso".
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 24.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”.
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.
- 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 24.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 Settings -> Storage
- In Storage Tree , Under IDE Controller , click Empty
- In Attributes , click the disk icon , select choose a virtual CD / DVD disk file…
- Choose "ubuntu-24.04.1-desktop-amd64.iso" you downloaded before
- 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.
-
Press the start button. to start the virtual machine for Ubuntu 24.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”.
Warning
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 :smile:.
- 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