Ubuntu 18.04 on Raspberry Pi 4

Hassan Shehawy
6 min readJan 15, 2021
Ubuntu 18.04 on RPi 4

I got my new Raspberry Pi (RPi) 4 and I was pretty excited to try out my RealSense camera since RPi finally comes with a USB 3 (which is required to get the RealSense camera working). I’m not an expert in Ubuntu, but I have installed it so many times with zero to little issues (issues popped up for instance when I was trying to install it on an external bootable hard disk, but eventually sorted this out and I’m even writing this using it). I always used the Ubuntu Desktop and I thought I’d do the same with my new RPi. However, it was not straightforward to me because I wanted specifically Ubuntu 18.04 (because I want to install ROS Melodic) and I wanted it the Desktop one, not the Server. Following the instructions on RPi on how to get Ubuntu for my RPi led me to this page: https://ubuntu.com/download/raspberry-pi which gave me the option to Ubuntu Desktop only for 20.10 and Ubuntu Server 20.04. I was considering installing ROS Noetic, but I can’t get it with 20.10, only 20.04 is supported. So if I will end up installing Desktop anyways, I thought I will just stick with my original plan (Ubuntu 18.04 and ROS Melodic). If you’re okay with Ubuntu 20.04, you can just follow the instructions on their page and skip to the Desktop installation section.

  1. What you need
  2. Burn Ubuntu on the SD card
  3. Setup WiFi
  4. Booting the RPi
  5. Ubuntu Desktop GUI
  6. Change connection handling to Network Manager
  7. Connect to RPi from your phone using ssh

What you need

Beside your RPi, you need a power adapter, microSD memory card, mouse, keyboard and a screen. You also need an image file for your desired Operating System (OS) and a program to burn your image file on the microSD card. I used the RPI Imager (as recommended by the RPi tutorials) and since I’m using Ubuntu on my laptop, I installed it inside my the terminal by typing:

sudo snap install rpi-imager

I assume you have snap installed, if not you can install it by the following commands:

sudo apt updatesudo apt install snapd

If you’re using another OS (Windows, MacOS), you can also get the RPI Imager from here: https://ubuntu.com/tutorials/how-to-install-ubuntu-desktop-on-raspberry-pi-4#2-prepare-the-sd-card

Burn Ubuntu on the SD card

Now, you just launch the Imager program and you get an interface like this:

Raspberry Pi Imager

Click on Choose OS and you will find a list of available images. The ones I got at the time of writing this were Ubuntu Desktop 20.10, Server 20.04 and Core 18. I had to look around for the 18.04 image for RPi and found it here: https://wiki.ubuntu.com/ARM/RaspberryPi#Download in the Download list.

If you know which image file to pick, skip this paragraph. If you’re not sure what arm64 and armhf are, these are just refereeing to the architecture and if you’re interested or curious to know more, see the Wikipedia page here: https://en.wikipedia.org/wiki/ARM_architecture . If you don’t care and want the long story cut short, you need to check your RPi technical specification and make the decision accordingly. For example, by looking at my RPi4 specifications here: https://www.raspberrypi.org/products/raspberry-pi-4-model-b/specifications/ I find it ARM v8 64-bit SoC and so I pick the arm64 image file. Just to illustrate it more on how to choose the image file, if you have a RPi2B and looked at the specifications here: https://www.raspberrypi.org/products/raspberry-pi-2-model-b/ you find it having an ARM Cortex-A7 CPU. A quick search shows that it implements ARMv7-A for which you would need armhf (hf is for hard floating).

After downloading the image file, go back to the RPi Imager. Click on Choose OS>Use Custom and locate the image file. You then need to click on Choose SD Card and locate your SD card. Finally click on Write and you’re done!

Setup WiFi

Now we need to set up WiFi to go on. While the SD card is still plugged and if you’re in a Linux environment, you should be able to see system-boot partition and browse its contents. We need a file named network-config to set up the connection. Many lines will be commented (if a line begins with a # it means it’s commented) and the following lines are the setup lines: (please note that you should have both the network name and password in quotations)

version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wifis:
wlan0:
dhcp4: true
optional: true
access-points:
“yourNetworkNname”:
password: “YOURpassword”

Booting the RPi

Now you can unplug your card and insert it in the RPi and boot it. This will be loading Ubuntu Server (unless you already have Ubuntu Desktop) and you will see a command line asking for username and password. Use ubuntu for both and it will ask you to change the password immediately. Congratulations! Now you have RPi running and up. Note that sometimes the WiFi connection doesn’t work when you get it running the first time, so just restart by typing the following:

sudo reboot

Ubuntu Desktop GUI

It’s time to get a Desktop GUI. So, we need to install it by typing the following:

sudo apt-get update
sudo apt-get install ubuntu-desktop

and then:

sudo reboot

Change connection handling to Network Manager

You should now have a Desktop GUI. However, if you try to change the WiFi network you will see that it’s unavailable from the settings on your Desktop. That’s because the connection is so far managed by Netplan (see more details here: https://netplan.io). If you want to manage your connections via the Network Manager, you need to edit the netplan yaml file. This file is located in /etc/netplan and it might have different name (mine was 50-cloud-init.yaml). So here is what to do:

ls /etc/netplan

You get to see the file here and know its name. Then you have to edit it:

sudo nano 50-cloud-init.yaml

You have to make it like this:

nework:
version: 2
renderer: NetworkManager

Finally reboot and you should be able to manage your connections and networks using the Network Manager.

Connect to RPi from your phone using ssh

One extra thing to try is using ssh tunneling with your phone. It might be useful for you and it’s a cool thing anyway to try.
You need a mobile app for that and my recommendation is Termius (it’s free and available for both Andoid and iOS). Check it here: https://termius.com

I assume you already have ssh installed and if you don’t know, you can check the status by typing:

sudo systemctl status ssh

You should see something like Active: active (running). If not and you get any errors, you can install it by typing:

sudo apt update
sudo apt install openssh-server

Follow the following steps in the app and make sure both your RPi and phone are connected to the same network:

Front Screen of Terminus

Tap on Hosts

Hosts Section in Terminus

Tap on the + to create a new one and provide the details of your RPi. You can give an alias for your connection (I named it rpi4 for example). You have to provide the IP, username and password. If you don’t know your RPi IP, you can check it by typing hostname -I in the terminal in your RPi.

Adding new host in Terminus

After you’re done, tap Save and you’ll be back to the hosts page. Tap on your connection and you should be able to connect (don’t worry about the security waning).

Connected to RPi

Awesome! We’re connected! Let’s try creating a text file and checking it from the RPi

Creating a text file with a simple text
From within the RPi

--

--