How To: Raspberry Pi boot from USB

The Pi enthusiasts have been waiting for official USB boot support on the Raspberry Pi for what feels like a lifetime, but finally it is on the horizon. In this post I will explain how to make your Raspberry Pi boot from USB.

Raspberry Pi boot from USB - exicode0

WARNING: Although this is official, it is still in beta testing, so rock-solid stability is far from certain. Learn more about this beta release here.

Why should I make my Raspberry Pi boot from USB?

Firstly let me address why you would want to do this and what makes many people relieved that the feature is on the horizon.

A more robust, long-lasting boot device. Micro SD cards, particularly high-quality cards, have come a long way and the days of a dead micro SD card seem to be dwindling. However, the small flash cards have a much shorter read/write life expectancy, and are not really designed to be used as a bootable OS media. Being able to use a SATA (over USB) device which was designed for the typical IO expected from an active operating system will ensure a long-lasting Pi setup.

Raspberry Pi boot from USB - SD card prices - exitcode0
32GB Sandisk Card Price over time – Camel Camel Camel

SATA based storage is cheaper per GB. Prices of micro SD cards have dropped significantly over the years, but SATA based storage is till better value for money at larger capacities, as well as the reliability benefits.

How do I make my Raspberry Pi boot from USB?

Difficulty:

Medium

There are a number of steps involved in this process and it will require you to bounce some files between devices that can be done on the Pi or by connecting the two bootable devices to another computer – this method won’t be covered in this guide.

Requirements:

Burn the Rasbian ISO to your SD card using something like Etcher: https://www.balena.io/etcher/ and plug it into the Pi.

Process (as of 23-05-2020):

The breakdown of the process:
1. Change the content of the EEPROM on the Raspberry Pi4 and set the boot device to USB.
2. Copy files from the boot directory of the SD card to the boot directory of the USB boot device.

We must start by updating the Raspbian installation:

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

Now that we are up to date, we must reboot before installing rpi-eeprom:

sudo reboot now
sudo apt install rpi-eeprom

Now we have to change the path of the Pi’s EEPROM firmware- this is done by moving from the critical channel to beta channel:

sudo nano /etc/default/rpi-eeprom-update

Replace ‘critical‘ with ‘beta‘ followed by ‘ctrl+x, y‘ to save and exit.

Now we can program the EEPROM as follows:

sudo rpi-eeprom-update -d -f /lib/firmware/raspberrypi/bootloader/beta/pieeprom-2020-05-15.bin

Followed by a reboot:

sudo reboot now

Once the reboot is complete, we can check the bootloader version as follows:

vcgencmd bootloader_version

If we run the follow…

vcgencmd bootloader_config

… we should see ‘BOOTORDER=0xF41. 4
‘.4’ means that USB boot is active; ‘.1’ means that SD boot is active.

At this point the Pi is ready, but the USB media is not. All that is left is to prepare the USB bootable media with the necessary files form our SD card installation.


Start by plugging in the USB getting rasbian flashed to your USB device in the same manner as the SD card – personally I use Etchor: https://www.balena.io/etcher/

Now we need to copy all ‘.elf’ and ‘.dat’ files from the boot directory of our SD card to the boot directory on the USB. Let’s start by mounting the USB drive.

sudo mkdir /mnt/usbdisk
sudo mount /dev/sd1 /mnt/usbdisk

Now that the USB drive is mounted, we can copy the required files:


sudo cp /boot/*.elf /mnt/usbdisk
sudo cp /boot/*.dat /mnt/usbdisk

We are done!

Now we can now power down (sudo shutdown now), remove the SD card, then power back up and check that we have successfully booted from out USB!


More Raspberry Pi Antics:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: