How to Install Ubuntu on Raspberry Pi
Learn how to install Ubuntu on Raspberry Pi using Raspberry Pi Imager. Configure headless WiFi, SSH access, storage expansion, and desktop GUI.

7 min read
Learn how to install Ubuntu on Raspberry Pi using Raspberry Pi Imager. Configure headless WiFi, SSH access, storage expansion, and desktop GUI.
- Prerequisites and Supported Releases
- Step 1: Choosing Between Ubuntu Server and Ubuntu Desktop
- Step 2: Installing and Launching Raspberry Pi Imager
The Raspberry Pi is the world's most versatile single-board computer (SBC), widely used for homelabs, IoT edge computing, home automation clusters, Kubernetes master nodes, and lightweight personal workstations. While Raspberry Pi OS is the traditional default distribution, deploying Ubuntu on Raspberry Pi delivers a true enterprise-grade 64-bit ARM (arm64) environment backed by Canonical's 5-year Long Term Support (LTS) lifecycle.
Running Ubuntu provides native parity with cloud server environments: you gain the exact same APT package ecosystem, systemd service management, Netplan networking definitions, and Docker container support that you use across production cloud infrastructure. Learning how to install ubuntu on raspberry pi enables you to transform a compact SBC into a robust, high-performance Linux server.
In this comprehensive tutorial, we cover the end-to-end installation of Ubuntu 24.04 LTS on Raspberry Pi 4 and Raspberry Pi 5. We walk through downloading and flashing the OS via Raspberry Pi Imager, configuring headless SSH credentials and Wi-Fi networks prior to first boot, connecting over the network, performing first-boot updates, and expanding storage.
Flash and configure Ubuntu Server or Ubuntu Desktop on Raspberry Pi 4 and 5 using Raspberry Pi Imager, customize headless WiFi and SSH, and initialize post-boot services.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A compatible Raspberry Pi single-board computer (Raspberry Pi 4, 400, or Raspberry Pi 5 recommended).
- A microSD card (at least
16 GB Class 10 / UHS-1, or 32+ GB for Desktop) or USB 3.0 SSD. - A host PC (Windows, macOS, or Linux) with an SD card reader to flash the operating system image.
- An official Raspberry Pi USB-C power supply to ensure reliable power delivery during compilation and heavy workloads.
Step 1: Choosing Between Ubuntu Server and Ubuntu Desktop
Before flashing your microSD card or NVMe SSD, decide which Ubuntu flavor best fits your project requirements.
Ubuntu Server (64-bit): Highly recommended for headless servers, microservice nodes, and Docker hosts. It has no graphical user interface (saving significant RAM and CPU cycles) and requires only 1 GB of RAM and an 8 GB SD card.
Ubuntu Desktop (64-bit): Designed for interactive desktop workstations connected to HDMI monitors. It includes a customized GNOME desktop with Wayland graphics acceleration, requiring at least a 4 GB RAM Raspberry Pi model and a fast 32+ GB microSD card or USB 3.0 SSD.
Ubuntu Server 24.04 LTS (arm64): Minimal footprint, optimal for headless IoT/servers
Ubuntu Desktop 24.04 LTS (arm64): Full GNOME GUI, requires Pi 4 (4GB/8GB) or Pi 5
Step 2: Installing and Launching Raspberry Pi Imager
The easiest, most reliable way to flash Ubuntu onto your storage media is using the official Raspberry Pi Imager utility. The tool runs on Windows, macOS, and Linux, and directly streams verified Canonical OS images.
Download and install Raspberry Pi Imager on your host computer from the official Raspberry Pi website, or install it via APT on an existing Ubuntu machine using sudo apt install -y rpi-imager.
Insert your microSD card or USB SSD into your computer's card reader and launch the application.
# Install Raspberry Pi Imager on Linux/Ubuntu host PC
sudo apt update && sudo apt install -y rpi-imager
# Launch imager
rpi-imager
Step 3: Selecting Device, Operating System, and Storage
Inside the Raspberry Pi Imager interface, follow the three-step selection wizard:
1. Raspberry Pi Device: Select your specific hardware board (e.g., Raspberry Pi 4 or Raspberry Pi 5).
2. Operating System: Click Choose OS > Other general-purpose OS > Ubuntu. Select Ubuntu Server 24.04 LTS (64-bit) for headless setups, or Ubuntu Desktop 24.04 LTS for GUI.
3. Storage: Select your target microSD card or external USB storage drive. Double-check that you have chosen the correct drive, as all existing partitions will be wiped.
Target Device: Raspberry Pi 5 / 4
OS: Ubuntu Server 24.04 LTS (64-bit arm64)
Storage: USB Drive / SD Card (/dev/sdX)
Step 4: Configuring Headless Customizations (WiFi and SSH)
Raspberry Pi Imager allows you to pre-configure system settings before flashing, enabling a completely headless installation without requiring an external monitor, keyboard, or Ethernet cable.
When prompted: 'Would you like to apply OS customization settings?', click Edit Settings.
Under the General tab, set your hostname (e.g., ubuntu-pi), create an administrative username and password, configure your Wi-Fi SSID and password, and set your wireless LAN country code.
Under the Services tab, check Enable SSH and select Use password authentication or paste your public SSH key from ~/.ssh/id_rsa.pub.
Save the settings, click Yes to proceed, and wait for the tool to write and verify the disk image.
Hostname: ubuntu-pi.local
User: ubuntu
Password: <secure_password>
Wi-Fi: SSID + WPA2 Password
SSH: Enabled (Port 22)
Step 5: Booting the Raspberry Pi and Locating IP Address
Once the flashing and verification processes finish, safely eject the microSD card from your computer and insert it into the card slot of your powered-off Raspberry Pi.
Connect the official USB-C power supply to boot the board. On initial boot, Ubuntu will resize the root partition to fit the entire storage capacity, configure cloud-init, and initialize SSH keys. This initial boot process takes approximately 2 to 3 minutes.
Find your Raspberry Pi's local IP address using mDNS, inspecting your router's DHCP client table, or using the nmap scanning utility from another machine on your local subnet.
# Ping using mDNS hostname
ping -c 3 ubuntu-pi.local
# Or scan your local subnet for Raspberry Pi MAC addresses (Raspberry Pi Foundation)
sudo nmap -sn 192.168.1.0/24 | grep -B 2 -i 'Raspberry'
Step 6: Connecting via SSH and Initial System Hardening
Connect to your Raspberry Pi over SSH from your workstation terminal using the administrative credentials configured during flashing.
Accept the host fingerprint when prompted to establish the encrypted session.
Upon connecting, immediately update all system package catalogs and apply all pending Ubuntu 24.04 security patches.
Verify the underlying Linux kernel architecture using uname -m to confirm that a full 64-bit aarch64 kernel is active.
# Connect to Raspberry Pi via SSH
ssh [email protected]
# Or using IP: ssh [email protected]
# Refresh repositories and apply updates
sudo apt update && sudo apt upgrade -y
# Verify 64-bit ARM architecture
uname -m
Step 7: Optimizing Storage and Configuring Swap Memory
Because single-board computers have fixed RAM constraints, configuring adequate swap memory is essential to prevent Out-Of-Memory (OOM) process crashes during heavy operations like compiling code or running Docker containers.
Ubuntu 24.04 typically creates a swapfile automatically. Check your active swap space using free -h or swapon --show.
If swap is inadequate, resize your swapfile to 2 GB or 4 GB, and adjust the kernel vm.swappiness parameter in /etc/sysctl.conf to preserve microSD card write endurance.
# Check active memory and swap status
free -h
swapon --show
# Reduce swappiness to minimize flash storage wear
sudo sysctl vm.swappiness=20
echo 'vm.swappiness=20' | sudo tee -a /etc/sysctl.conf
Step 8: Installing Desktop Environment (Optional)
If you originally installed Ubuntu Server but later decide you need a graphical user interface, you can install a desktop shell directly over APT.
For maximum performance on Raspberry Pi hardware, lightweight desktop environments like XFCE or LXDEn (Lubuntu) are recommended over full GNOME.
Run the command below to install XFCE and reboot your Raspberry Pi to initiate the graphical display manager.
# Install lightweight XFCE desktop environment
sudo apt install -y xfce4 xfce4-goodies
# Or install full standard Ubuntu Desktop
# sudo apt install -y ubuntu-desktop
# Reboot to start graphical manager
sudo reboot
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
Raspberry Pi fails to connect to Wi-Fi on first boot
Resolution: Ensure your Wi-Fi credentials in Raspberry Pi Imager are correct and that the Wi-Fi country code is set properly. Note that Raspberry Pi 4 and 5 support both 2.4 GHz and 5 GHz networks, while older boards support 2.4 GHz only. You can reconfigure Wi-Fi by editing /etc/netplan/50-cloud-init.yaml and running sudo netplan apply.
System boots with low-voltage warnings or throttles CPU
Resolution: Under-voltage causes silent data corruption on microSD cards and system freezes. Ensure you are using the official 27W USB-C power supply for Raspberry Pi 5 or the 15W supply for Raspberry Pi 4. Monitor throttle state with vcgencmd get_throttled.
SD card runs out of space despite having a large card
Resolution: Although cloud-init automatically expands the filesystem on first boot, you can manually force partition expansion by running sudo growpart /dev/mmcblk0 2 && sudo resize2fs /dev/mmcblk0p2.
Security Best Practices and Hardening
Change default user passwords immediately on first boot. Avoid leaving default credentials like 'ubuntu:ubuntu' active on exposed networks.
Disable SSH password authentication in /etc/ssh/sshd_config and rely exclusively on Ed25519 or RSA public key authentication.
Enable Ubuntu's built-in UFW firewall by running sudo ufw allow 22/tcp && sudo ufw enable to block unauthorized incoming connections.
Configure unattended security upgrades using sudo apt install -y unattended-upgrades to keep kernel and security patches updated automatically.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
gpiod and libgpiod-dev packages along with the rpi.gpio-common package, allowing full Python and C/C++ control over 40-pin GPIO headers, I2C, and SPI buses.cat /sys/class/thermal/thermal_zone0/temp (divide output by 1000 for Celsius) or using the vcgencmd measure_temp utility.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides


Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!