Install Ubuntu on Raspberry Pi

Install the 64-bit ARM variant of Ubuntu on a Raspberry Pi.
  1. Download image
  2. Locate SD card
  3. Unmount SD card
  4. Install coreutils
  5. Image SD card
  6. Initial boot
  7. References

The following instructions are for headless (i.e. without a monitor) Raspberry Pi server installation of Ubuntu using a machine running macOS.

Download image

Download the latest Ubuntu for Raspberry Pi 64-bit ARM image.

version="20.04"
img_file="ubuntu-${version}-preinstalled-server-arm64+raspi.img"
xz_file="${img_file}.xz"
url="http://cdimage.ubuntu.com/releases/${version}/release/${xz_file}"
wget "$url"

Check that the image file downloaded successfully.

checksum="48167067d65c5192ffe041c9cc4958cb7fcdfd74fa15e1937a47430ed7b9de99
echo "${checksum} *${xz_file}" | shasum -a 256 --check

You should see this return:

ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz: OK

Extract the compressed image file.

xz -d "$xz_file"

Locate SD card

Locate the mount point of the SD card (e.g. /dev/disk2).

The SD card should look somewhat like this, depending on the size of the card, and how many drives you have attached.

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *32.0 GB    disk2
   1:             Windows_FAT_32 boot                    268.4 MB   disk2s1
   2:                      Linux                         31.7 GB    disk2s2

Be careful with this step to ensure that you don’t select the wrong drive.

n="2"

Unmount SD card

Check active mounts and unmount the target disk.

diskutil unmountDisk "/dev/disk${n}"

You should see something like:

Unmount of all volumes on disk2 was successful

Double check mount status with:

mount
df -H

Install coreutils

I recommend installing the GNU coreutils variant of dd first via Homebrew, and using that version instead of the default BSD variant that ships with macOS.

brew install coreutils

Image SD card

Now you’re ready to format the SD card using dd.

# Input file.
if="ubuntu-20.04-preinstalled-server-arm64+raspi.img"

# Output file.
# Note the use of 'rdisk' here, for raw disk access.
of="/dev/rdisk${n}"

sudo dd if="$if" of="$of" bs="32M" status="progress"

Now we’re ready to eject the disk and boot up the Raspberry Pi device.

sudo diskutil eject "$of"

Initial boot

The default admin account is ubuntu, with the password ubuntu.

SSH access on the Ubuntu image is enabled by default, unlike Raspberry Pi OS.

Additional configuration is available in our Raspberry Pi cheat sheet.

References