Setting up Ubuntu 21.04 on the Raspberry Pi | BlogJawn

Posted by William 'jawn-smith' Wilson on Fri 16 April 2021

Today's tutorial will explain how to set up Ubuntu on the Rasbperry Pi. It will cover the differences between the server and desktop versions of Ubuntu, as well as the armhf and arm64 builds of Ubuntu. As of the writing of this tutorial, Ubuntu 21.04 (Hirsute Hippo) is nearly released. It has a newer kernel (5.11) than the 20.10 release and some features I will cover in other blog posts, so I will use it for this tutorial. Once it has officially released I will update the URLs in this post.

Server vs Desktop

Server

The server version of Ubuntu 21.04 is a small, lightweight image with no desktop environment. It uses the command line for everything as it has no graphical software installed. Its lightweight nature makes it perfect for hosting websites like this one, automating tasks, and for users who want the most performance from their Pi. This will be the only option for Raspberry Pi models with less than 4GB of RAM.

armhf vs arm64

There are two different architectures of Ubuntu Server available: armhf and arm64. The armhf version is a 32 bit OS, while the arm64 version is 64 bit. On a Raspberry Pi with 4GB of RAM or more, the arm64 architecture is recommended to make full use of CPU and memory optimizations. On models with less than 4GB of RAM, the armhf architecture is recommended.

Desktop

The desktop version of Ubuntu 21.04 is a larger image with more resources consumed. It comes with the full gnome desktop environment, allowing you to browse the web, edit photos, and more. It's great for users that want to log in and use their Pi as a desktop computer, or for newer users who are less comfortable with the command line.

Which is right for you?

If you want to log into a graphical environment, the desktop version is the best choice. You will need a Raspberry Pi 400 or a Raspberry Pi 4 with at least 4GB of RAM to use this effectively. The desktop version only comes as an arm64 OS, so no need to choose between the two architectures. If you have an older Pi, or prefer to do everything on the command line, the server version is the best option. If your Pi has less than 4GB of RAM, I recommend the armhf version.

Downloading and installing

The following instructions will assume the user is on a Linux machine. Many other tutorials exist for Windows users

Now that you have chosen the best version of Ubuntu 21.04 for you, you will need to download it.

To download the armhf server image, run the command wget https://cdimage.ubuntu.com/releases/21.04/release/ubuntu-21.04-preinstalled-server-armhf+raspi.img.xz

To download the arm64 server image, run the command wget https://cdimage.ubuntu.com/releases/21.04/release/ubuntu-21.04-preinstalled-server-arm64+raspi.img.xz

To download the desktop image, run the command wget https://cdimage.ubuntu.com/releases/21.04/release/ubuntu-21.04-preinstalled-desktop-arm64+raspi.img.xz

Once you have downloaded the image, uncompress it by running unxz <path/to/image.xz>.

Flashing the image via command line

To flash the image to the SD card via the command line, run dd if=</path/to/image.img> of=/dev/mmcblk0 bs=1M status=progress. This command assumes you have the SD card plugged into the SD card slot of the computer. If you are using a USB adapter it may appear as /dev/sdb or something similar instead.

Note: be very careful about the of argument in the previous command. If the wrong disk is used, you may lose your data.

Flashing the image with a GUI

If you are more comfortable using a GUI to flash the image to the SD card, there's a tool for that! It's called RPi Imager and it's available from a few different places. On Ubuntu, you can install it by running sudo snap install rpi-imager. It's also available for download from the Raspberry Pi foundation. It runs on Linux, Windows, and MAC. To choose the recently decompressed image, click the "CHOOSE OS" Button and scroll down to "Use custom". Select the Ubuntu 21.04 image, select the SD card in the "Storage" drop-down menu, and click "WRITE".

Imager Use Custom

Now that the image has been flashed to the SD card, you can boot plug it into the Raspberry Pi and boot it up!

Installing and using Vim or Nano

In order to follow future tutorials, you will need a text editor to paste and edit code. My preferred text editor is Vim. It has a fairly steep learning curve, so there is also Nano that can be used instead. Both the server and desktop Ubuntu images have Nano installed by default. If you are on the desktop and would like to use Vim, you will need to run sudo apt install vim.

If you have another text editor you prefer or you are already comfortable with Vim/Nano, you can skip this part. Otherwise you can read Guide for using Nano or Guide for using Vim