archive2022

Booting a Raspberry Pi 4 from a USB SSD

Why an SSD is a good upgrade for a Pi 4 that runs all the time, how to set it up, and which USB adapters cause trouble.

3 min read#edge#raspberry-pi#storage

New Raspberry Pi boards are hard to buy right now. Many shops are out of stock, and reseller prices are high. So I am making the Pis I already have more reliable, and for a Pi 4 that runs all the time that means booting from a USB SSD instead of the SD card.

SD cards wear out with many small writes, and logs, databases and Docker do exactly that. An SSD is also much faster for random reads and writes, so package installs and container starts are quicker. A small SATA SSD plus a USB 3 adapter does not cost much. For a Pi that mostly reads, like a kiosk or a display, I would keep the SD card.

Bootloader first

The Pi 4 boots from USB only with a recent bootloader in the EEPROM:

sudo apt update && sudo apt full-upgrade -y
sudo rpi-eeprom-update

If an update is available, apply it and reboot:

sudo rpi-eeprom-update -a
sudo reboot

Then check the boot order:

vcgencmd bootloader_config | grep BOOT_ORDER

BOOT_ORDER=0xf41 means try the SD card (1), then USB (4), then restart (f). That is the normal default, so with no SD card inserted the Pi boots from USB. sudo raspi-config can change the order under Advanced Options, Boot Order.

Write the image

Connect the SSD to your PC with the adapter and write it with Raspberry Pi Imager, the same as an SD card. In the advanced options (Ctrl+Shift+X) set the hostname, enable SSH and set the password.

Then remove the SD card from the Pi, connect the SSD to a blue USB 3 port, and power on. Check where root is mounted:

findmnt /
lsblk -o NAME,SIZE,MODEL,TRAN

The root filesystem should be on /dev/sda2, and the transport should say usb.

The adapter problem

Most problems come from the USB-to-SATA adapter, not the SSD. Some adapter chips do not work well with the UAS driver on the Pi. You see a very slow disk, I/O errors, or a Pi that does not boot.

dmesg | grep -i -E 'uas|usb-storage|reset'

If there are repeated resets, disable UAS for that adapter. Find its vendor and product ID:

lsusb
# Bus 002 Device 002: ID 174c:55aa ASMedia ...

Add this at the start of the single line in /boot/cmdline.txt, with your own IDs:

usb-storage.quirks=174c:55aa:u

After a reboot the disk is a bit slower, but stable. Buying a different adapter is the other fix. I do not know a good way to tell which adapters work before you buy one.

Power

The SSD takes its power from the Pi’s USB ports. Use the official 3 A power supply. If you see “under-voltage” in dmesg, use a powered USB hub or an adapter with its own power input.

I keep one SD card with a working image in a drawer. When the SSD setup has a problem, it is the fastest way to get a shell and look.