How to Install Ubuntu on Raspberry Pi

December 3, 2024

Introduction

Raspberry Pi typically uses Raspberry Pi OS, a Debian-based system optimized for Pi hardware. However, developers and power users prefer Ubuntu for its regular updates, familiar interface, and extensive features.

With many Ubuntu versions available, such as Ubuntu Mate, Server, or Core, there are multiple options to choose from. Despite differences in hardware and versions, the steps to prepare and install Ubuntu on a Raspberry Pi device are similar.

This guide provides instructions on how to install Ubuntu on Raspberry Pi.

how to install ubuntu on raspberry pi 3 on ubuntu 18.04

Prerequisites

  • A Raspberry Pi device (version 2 or later). Check compatibility with the Ubuntu version (Desktop, Server, Core, or MATE).
  • A storage device (microSD card or USB drive) with at least 8GB capacity (16GB recommended).
  • A microSD card reader or USB port.
  • A system running Windows, macOS, or Linux to prepare the bootable image.

Installing Ubuntu on Raspberry Pi

Installing Ubuntu on a Raspberry Pi requires downloading the correct Ubuntu image, preparing the storage device, and booting the system from that device.

Follow the steps below to see how to install Ubuntu on Raspberry Pi.

Step 1: Download Ubuntu Image

Download the Ubuntu image for Raspberry Pi. There are several versions designed for different configurations:

1. Choose an Ubuntu version that best suits your device:

  • Ubuntu Desktop features a complete desktop environment.
  • Ubuntu Core is a minimal and lightweight OS suitable for IoT and embedded apps.
  • Ubuntu Server is a lightweight server OS without a GUI.
  • Ubuntu MATE is a resource-friendly desktop environment with a lightweight GUI.

2. Visit the appropriate Downloads page to download the image:

Ubuntu Core downloads page
Ubuntu MATE downloads page

3. Choose an appropriate image for your Raspberry Pi model:

  • Raspberry Pi 2 or 3 uses 32-bit images for optimal performance.
  • Raspberry Pi 4 and later can use either 32-bit or 64-bit images, depending on the requirements.

4. Download the file and save it on the local machine. The file is a compressed .xz image.

Step 2: Extract Image

When the download completes, extract the .img file using a decompression tool. The steps differ between operating systems.

Extract Image on Linux

Linux users can extract the file via the terminal:

1. Use the cd command to navigate to the file's location. Typically, the file is saved in the Downloads directory:

cd ~/Downloads

2. Run the following command to extract the file:

xz -d [file_name].img.xz
extract xz -d ubuntu MATE .img.xz terminal output

Replace [file_name] with the actual name of the downloaded file.

Extract Image on macOS

macOS users can utilize the Unarchiver tool to extract the image file:

1. Locate the .xz file in Finder (typically in the Downloads folder).

macOS Ubuntu MATE img.xz downloaded file

2. Double-click the file to start the extraction.

macOS Ubuntu MATE extracted .img file

The .img file is saved in the same location after extraction.

Extract Image on Windows

Windows users can use an extraction tool, such as 7-Zip:

1. Locate the .xz file in the File Explorer.

2. Right-click the file and select 7-Zip->Extract Here. Alternatively, select Extract files and choose a different destination.

Windows 7-zip Extract here ubuntu MATE img.xz file explorer

The .img file appears in the specified location after extraction.

Step 3: Format microSD Card or Flash Drive

Before writing the Ubuntu image, format the storage device to ensure compatibility with Raspberry Pi during the boot process. The recommended file system is FAT32, and the format process is identical for both storage devices. Insert the card or drive into a computer and follow the steps below based on your OS.

Important: Formatting a storage device erases all data stored on it. To prevent data loss, back up any sensitive data before formatting.

Format on Linux

To format a storage device on Linux:

1. Open the terminal and list all connected devices:

lsblk
lsblk sdb drive terminal output

Identify the device name from the list.

2. Unmount the device:

sudo umount [partition_path_or_name]

3. Format the device to FAT32 with:

sudo mkfs.vfat -F 32 /dev/[device_name]
umount and format fat32 device terminal output

The command formats the device.

Format on macOS

Use the Disk Utility to format the storage device on macOS:

1. Open Applications->Utilities->Disk Utility.

2. Locate the storage device on the list and select it.

3. Click the Erase button in the top menu.

macOS USB drive erase

4. Choose "MS-DOS (FAT)" as the format.

macOS USB drive FAT32 erase

5. Click Erase to confirm and format the card or drive.

Format on Windows

To format the storage device on Windows, use the File Explorer:

1. Right-click the storage device and select Format.

2. Set the file system to FAT32 and leave the other options unchanged.

3. Click Start to confirm.

Windows tool to format SD card

The process erases all the data and formats the device to the selected file system type.

Step 4: Write Ubuntu Image to SD Card or Flash Drive

After formatting the storage, write the .img file onto the device. There are multiple ways to write the file depending on the operating system and preferred tools.

Write Ubuntu Image via Terminal

Use the terminal on Linux or macOS systems to write the image:

1. Navigate to the directory where the .img file is:

cd ~/Downloads

2. Use the dd command to write the image to the device:

sudo dd bs=1M if=[image_name].img of=/dev/[device_name] conv=sync status=progress
sudo dd ubuntu MATE flash drive write terminal output

Replace [image_name] with the .img file name and the [device_name] with the storage device. The command shows the writing progress.

3. The writing process takes some time. Wait for it to complete, then eject the device safely.

Write Ubuntu Image via Raspberry Pi Imager

The Raspberry Pi Imager is an official imaging utility available for Linux, macOS, and Linux. The utility can be downloaded from the official Raspberry Pi software page.

To write an Ubuntu image using the imager, launch the application and do the following:

1. Click Choose Device and select the Raspberry Pi device from the list.

2. Select Choose OS->Use custom.

Raspberry Pi Imager use custom OS option

Locate and select the .img file.

3. Insert the storage device and select it under Storage.

Raspberry Pi Imager choose storage

4. Click Next to proceed.

Raspberry Pi Imager selected options

5. Choose whether to edit OS settings or to proceed with default ones.

Raspberry Pi Imager OS customisation

6. Confirm the data deletion from the storage device to start the flashing process. Wait for it to complete before proceeding.

Write Ubuntu Image via Etcher

Etcher is another cross-platform tool for writing disk images. Download and install the balenaEtcher tool from the official website.

Note: For an in-depth tutorial on installing Etcher on Ubuntu, visit our article How to Install Etcher on Ubuntu. The guide offers two installation options, via GUI or terminal.

Start the program and follow the steps below:

1. Select Flash from file and locate the .img file.

balenaEtcher Flash from file button

2. Click Select target and choose the storage device.

balenaEtcher Select target button

3. Once ready, click Flash to write the disk image.

balenaEtcher Flash! button

Wait for the flash process to complete.

Step 5: Boot Ubuntu

Once the storage device is prepared with an Ubuntu image, boot the Raspberry Pi device into Ubuntu:

1. Insert the storage device into the appropriate port on the Raspberry Pi.

2. Connect the essential peripherals (power cable, display, keyboard, and mouse). If working in headless mode, refer to our guide to enable SSH on Raspberry Pi.

3. Turn on the Raspberry Pi device by plugging in the power cable.

4. The device goes through the boot sequence and loads the Ubuntu OS installation.

Install Ubuntu MATE screen Raspberry Pi

Follow the on-screen instructions to complete the installation steps.

Step 6: Update Ubuntu

Once the system fully loads on your Raspberry Pi, run the updater to get the latest software and security patches. Open the terminal and run the apt update and upgrade commands:

sudo apt update
sudo apt upgrade

Alternatively, use the Software Updater GUI tool to update and upgrade. After updating, reboot the system:

sudo reboot

The device is ready to use with a fresh Ubuntu installation.

Configuring Ubuntu on Raspberry Pi

After installing, updating, and upgrading Ubuntu on Raspberry Pi, continue by configuring the system and adjusting the default settings. Below are some common post-installation steps that help set up essential features.

Wi-Fi Setup

To connect the Raspberry Pi device to a wireless network, use the GUI or terminal. Click the network icon, select or add the desired network, and enter the password when prompted.

Ubuntu 24.04 network GUI

If in a headless setup, use the terminal instead:

1. Open the Netplan configuration file for editing:

sudo nano /etc/netplan/50-cloud-init.yaml

2. Locate or add the wifis section and provide the Wi-Fi credentials:

wifis:
    wlan0:
        dhcp4: true
        access-points:
            "[SSID]":
                password: "[password]"
Ubuntu netplan wifis settings Raspberry Pi

Replace [SSID] and [password] with the actual values.

3. Save the file and close nano (CTRL+X, Y, Enter).

4. Apply the configuration:

sudo netplan apply

The device connects via a wireless connection based on the provided information.

Change Hostname

To modify the device's hostname, use the following command:

sudo hostnamectl set-hostname [new_name]

Restart the terminal to see it applied. Changing the hostname makes it easier to identify the Raspberry Pi device on the network.

Additional Configuration

Additional setup and configuration depend on the device's use and purpose. For instance:

Conclusion

This tutorial showed how to prepare a storage device and install Ubuntu on Raspberry Pi. Follow the sections for your OS to complete the process.

Next, see how to set up a Raspberry Pi DNS server to reduce DNS lookups.

Was this article helpful?
YesNo
Milica Dancuk
Milica Dancuk is a technical writer at phoenixNAP with a passion for programming. With a background in Electrical Engineering and Computing, coupled with her teaching experience, she excels at simplifying complex technical concepts in her writing.
Next you should read
How to Install Java on Raspberry Pi
July 18, 2024

This article guides you through the Java installation process on Raspberry Pi. You will also learn how to set...
Read more
How to Update Raspberry Pi
December 10, 2024

Update your Raspberry Pi to keep it secure. In this guide you can also learn how to upgrade from an old to...
Read more
How to Enable SSH on Raspberry Pi
October 15, 2024

This article shows you how to enable SSH on your Raspberry Pi using different methods. The guide...
Read more
How to Install Docker on Raspberry Pi
December 12, 2019

If you want to install Docker on Raspberry Pi, that is on its Raspbian system, you need to use...
Read more