How To - Ubuntu on Raspberry Pi

Summary

Steps on how to install and configure Ubuntu Server 22.04 on a Raspberry Pi (RPI).

Note: my host PC runs Ubuntu Desktop 22.04 so some of the instructions below may be specific to that OS.

Initial

RPI info

  • choose a userid for the rpi account: e.g. rpi_userid
  • choose a password for the rpi account: e.g. rpi_password
  • choose a hostname for the rpi: e.g. rpi_name

Create SD-Card

install rpi imager

  sudo snap install rpi-imager

insert microSD card

  • use at least 32GB (more is better)
  • check it's mounted using file manager

start rpi-imager

  • Raspberry Pi Device: Raspberry Pi 4
  • Operating System:
    • click Choose OS
    • click Other General-purpose OS
    • click Ubuntu
    • click Ubuntu Server 22.04.4 LTS (64-bit) (Note: not desktop)
  • Storage:
    • click Choose Storage
    • click "Internal SD card reader ..."
    • click Next
  • Use OS customisation?

    • click Edit Settings
    • dlg box OS Customisation
      • select General tab (default)
        • select hostname: rpi-name
        • select Set username and password: enter rpi_username, rpi_password
        • if using wireless, select Configure wireless LAN
          • enter your SSID and its password
        • Check timezone and keyboard layout is correct
      • select Services tab
        • select Enable SSH
        • ensure "Use password authentication" is selected
        • ensure "Allow public-key authentication only" is not selected
      • select Options tab
        • check and you wish
    • click Save
    • click Yes on dlgbox "Use OS customisation?"
  • dlgbox Warning: All existing data ... wll be erased. Are you sure?

    • click Yes
  • dlgbox Authentication required, enter password
  • "preparing to write..." takes 5m

  • dlgbox Write Successful, click Continue

  • close rpi-imager

eject SD Card media

  • remove the SD Card from your host PC

insert SD Card into RPI

  • ensure RPI is off
  • move SD card to RPI
  • power on the RPI
  • wait for it to boot up

set up static IP address on your router

  • set the IP address as a static address in your router:

    • Note: I have a tp-link AX-3000 router, your instruction will be different
    • open Router, goto to Advanced, DHCP Server
    • find rpi_name
    • add it to Address Reservation to maintain the same IP address
  • Note: setting the ip address to static will ensure that the /etc/hosts doesn't need to change, the ssl key doesn't change etc.

  • add it to /etc/hosts on your host PC

10.0.0.xx        rpi_name

Configure RPI

start ssh terminal and login to rpi

ssh rpi_userid@rpi_name

ip address
# confirm it is the 10.0.0.xx address you set in your router

ping google.com
# confirm access to internet

Update RPI ubuntu

sudo apt update
sudo apt upgrade
sudo apt autoremove
sudo apt autoclean

setup datetime and timezone

# set timezone, otherwise some utilities such as rsync can be confused by different timestamps
sudo apt install -y ntpdate
sudo timedatectl set-ntp off
sudo timedatectl set-ntp on
# Note: change to your appropriate timezone
sudo timedatectl set-timezone America/Edmonton

reboot to pick up latest changes

sudo reboot
# Note: takes 2+m to reboot and have SSH access

Done!

At this point, the RPI can be accessed from any OS or utility that supports SSH e.g.

  • Ubuntu or other linux bash terminal
  • Windows MSYS2 terminal
  • macOS terminal
  • apps like putty

check rsync works

# send a directory from your host PC to the rpi's home directory
rsync -avhc some_host_dir/ "rpi_userid@rpi_name:/home/rpi_userid/some_rpi_dir/"

# ssh into the RPI and check the directory ~/some_rpi_dir exists and has the correct content

- John Arrizza