Raspberry Pi4 - Setup Ubuntu Server with boot from USB SSD

Raspberry Pi4 - Setup Ubuntu Server with boot from USB SSD

The Hardware

The Pi

image.png

The device is a Raspberry Pi 4B with 8GB RAM.

raspberrypi.org/products/raspberry-pi-4-mod..

The case

image.png

owootec RetroFlag ResPi4. This case is an amazing combination of several things - the NES controllers to play Super Mario and Contra again (using RetroPie!). And also inbuilt interface for 2.5" SSD drive through USB 3.0. And a nifty case with a 32GB SD card and fan included. Highly recommend this one!

amazon.se/gp/product/B08FJ5BG52

The SSD

image.png

Crucial CT240BX500SSD1. Although I was a little skeptical because not all SSDs are known to be compatible with the raspberry pi and I have had my share of trouble to get it to work!

amazon.se/gp/product/B07G3YNLJB

The operating system

The operating system included in the SD Card that comes with the NesPi4 case included the Raspbian OS (default OS for the raspberry pi).

If the card is empty or contains a different OS, you may choose to install Raspbian on it. I used my ASUS laptop which had a SD card reader for this.

Raspi Imager Tool

This step is needed if the SD card doesn't already have Raspbian OS.

Get the raspi-imager from raspberrypi.org/software and install it.

Insert the SD Card and run the tool. The interface is pretty straightforward. Choose OS (in our case Raspbian - 32 or 64 bit does not matter), choose device, and click on Write. The tool downloads the prebuilt OS image and writes it onto the card. It also takes care of formatting and partitioning the disk correctly.

Configure

On first boot, the OS needs some setup. Choose the locale settings and connect to a network. Then choose a password and finish the rest of the setup wizard. Skip the reboot option.

Run the terminal application and:

sudo apt update -y

sudo apt full-upgrade

Once the update is complete:

sudo reboot

Verify

After reboot, verify that there are no errors and you are able to see the SSD drive correctly:

df -h

OR

lsblk

You should be able to see two disk drives - one for the SD card and the other for the SSD disk.

Setting up the SSD

We need to install the Ubuntu server image on the SSD and set it as the default boot option.

Install Raspi Imager

We need the Raspi Imager tool again. This time, the SSD drive acts as the target for the OS flash.

sudo apt install raspi-imager

Run it: Applications -> Accessories -> Imager

Choose the OS, choose the SSD drive as target and click Write.

For the OS, choose Ubuntu Server 20.10 - I faced multiple issues with the Ubuntu 20.04 LTS version of the image. Could be the combination of the SSD make/model or some driver files not working correctly (see note below).

Setup boot from USB

sudo raspi-config

Choose Advanced Options --> Boot order --> Select primary boot as USB, fallback to SD card option.

Accept and restart.

The device should now boot into Ubuntu Server 20.10.

User setup

The first start, the system prompts for login, use ubuntu for both login and password. It will complain that it is wrong, but it will auto-generate the password and present the prompt again.

Again, use ubuntu as login and password. This time, it will force to set a new password. Once the password is set, you will be able to login.

Configure Wifi

Since there is no UI, it is a bit tricky to setup the Wifi. Edit the netplan file:

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

Add the wifis: section as below:

network:
  ethernets:
    eth0:
      dhcp4: true
      match:
        driver: bcmgenet .....
      optional: true
      set-name: eth0
  version: 2
  wifis:
    wlan0:
      dhcp4: true
      optional: true
      access-points:
        "SSID-NAME"
          password: "PASSWORD"

Save the file and apply changes:

sudo netplan apply

It will take some time for the network detection and connection to occur. Verify by:

ip a

Run the command several times until wlan0 status is UP and you see a local IP address assigned by DHCP.

Update system

Run:

sudo apt update -y

and:

sudo apt full-upgrade

Note: At the time of writing, the Ubuntu 20.04 LTS version failed to boot correctly multiple times, each time with a different issue -

  • It failed to boot the first time, always defaulted to the SD card. When booting without the SD card, it failed to read the boot files correctly.
  • On rewriting the OS again, it failed with "USB failed to respond to voltage check!" - which was possibly because of a power issue, but I knew it wasn't because the SSD had booted correctly with Raspbian OS before.
  • Yet again, the SSD boot failed sometimes on the multicolor screen of death! Again attributed to power issues - I also tried a different power adapter, with no luck.
  • I did get it to boot finally, but this time, it failed to recognize the WiFi network interface (service error on startup).

Finally, I decided to attribute it to the Ubuntu 20.04 OS image itself, and reluctantly tried the Ubuntu 20.10 version - which to my surprise worked like a breeze! No more issues.