Setting Up a Raspberry Pi Zero 2 W with Ubuntu Server

Published: 2024 January 04

system administration Linux home lab Raspberry Pi Raspberry Pi Zero 2 W

Introduction

This is a guide for installing Ubuntu Server on a Raspberry Pi Zero 2 W via a headless setup using the Raspberry Pi Imager and another computer running Linux.

Many of the steps are outlined in the Raspberry Pi Foundation’s Documentation in the Getting Started Guide.

There are a few additional steps and helpful details that this guide is intended to provide for a smooth setup.

Parts for the Pi

There are several necessary components:

Building the OS image for the Pi

The next step is to install the desired operating system (OS) image on bootable media.

The Raspberry Pi Imager is very helpful for creating a bootable OS image and configuring it for a headless setup.

On Ubuntu, the Raspberry Pi Imager can be installed with:

sudo apt install rpi-imager

Once the Imager is installed, open it and select the following settings (or substitute your own):

Operating System

CHOOSE OS > Other general-purpose OS > Ubuntu > Ubuntu Server 22.04.3 LTS (64-bit)

Note:

Storage

CHOSE STORAGE > {Select the appropriate SD card}

Note: Take care to select the correct storage as whatever drive you select will be completely overwritten and all data erased.

Advanced Options (Gear Icon in the lower right)

Select and fill the following fields:

☑️ Set hostname: {DESIRED_DEVICE_NAME}

☑️ Enable SSH

🔘 Use password authentication

☑️ Set username and password

☑️ Configure wireless LAN

Note: This must be a 2.4GHz WiFi network for the Pi to connect with it.

☑️ Set locale settings

Click SAVE.

Review the information and build the OS image

Once you have entered and confirmed all the above information, click WRITE.

If you are sure you have selected the correct media and settings, click YES.

Wait for the writing and verification steps to complete.

Read the system message to confirm succesful OS image writing. If there was an error, repeat the imaging steps.

Assembling the Pi

Assembling the Pi is straightforward:

  1. Insert the micro SD card.
  2. Place the Pi in the case.
  3. Plug the power supply into the correct micro USB port.

Powering the Pi

To turn it on, you only need to supply power.

Give the Pi a few minutes to boot.

Connect to the Pi over the Local Network

Connecting to the Pi can involve a few steps:

  1. Identify the IP address of the Pi.
  2. Connect to the Pi over SSH.

Identify the IP address of the Pi

Identifying the IP address of the Pi can be accomplished in several ways.

For instance, you can log in to your router and search through the WiFi-connected devices.

Another approach is to use another computer to search your WiFi network for the device. We’ll look at that approach here.

First, identify the IP address of the computer you’ll use to conduct the search by running the ip command:

ip -brief address

Look for addresses identified as ‘UP’ and identify which is the IP address of your search computer.

For this example, let’s say the address is 192.168.0.6.

Next, use the nmap command and the IP address you just found to search the network for other connected devices.

sudo nmap -sn 192.168.0.6/24

From the list that nmap generates, identify the IP address for the Pi.

Connect to the Pi over SSH

Now, we can use SSH to connect to the Pi.

The command uses the form ssh {username}@{ip-address}, so for a user of pi and an IP address of 192.168.0.12 we’d enter the following:

ssh pi@192.168.0.12

During your first login to a host, you’ll see a warning message:

The authenticity of host ‘192.168.0.12 (192.168.0.12)’ can’t be established.

Are you sure you want to continue connecting?

If you believe you have connected to the correct device, type ‘yes’ and press Enter.

When prompted, enter the password you assigned for the account.

You should be greeted with a welcome message:

Welcome to Ubuntu 22.04.3 LTS

Updating the Pi

Once you have connected to the Pi, finalize the setup by updating the system:

sudo apt update && sudo apt upgrade && sudo apt autoremove

Confirm the update completed successfully.

Afterward, you will likely need to reboot to apply all changes:

sudo shutdown --reboot now

Conclusion

With the above steps completed, the Raspberry Pi Zero 2 W is ready for use.

Copying Directory Structure With a Bash Script - With Help From ChatGPT AI

Published: 2024 January 22

Setting Up a Raspberry Pi as a Linux Print Server with CUPS

Published: 2024 January 19

Bash and The Linux Shell - Basic Terminal Command Quick Reference

Published: 2023 October 18