Boot from USB on your Raspberry Pi

Booting off of your SD card should be fine in most cases, and there's no speed penalty for doing so or anything, but what if you just wanted to boot off your larger USB connected SSD drive to keep things simple? This is how you can do that.

Just don't have an SD card inserted. By default, the Pi will attempt to boot off of its SD card, and if that fails then it will attempt to boot off of the USB drive. A few things to keep in mind, though:

  • Ensure that the Pi can read the drive first before attempting to boot off of it.
  • USB hard drives take up a lot of power, much more so than standard USB sticks. You probably won't be able to use a full sized mechanical hard drive. But if you are using a 2.5“ mechanical or solid-state drive, ensure that you are using the official power supply appropriate to your Pi model. Even on non-official supplies that are otherwise “high enough”, the booting procedure takes the most power of all and a non-official power supply may stutter, causing boot issues (or possibly even data corruption!)
  • The Raspberry Pi can only boot on devices up to USB 2.0. Some USB 3.0 drives have been reported as bootable, but the official statement is “the Pi cannot boot with USB 3.0 drives”.
  • The default timeout for checking bootable USB devices is 2 seconds. Some flash drives and hard disks power up too slowly.
  • Some flash drives have a very specific protocol requirement that is not handled by the bootcode and may thus be incompatible.

If you'd rather have the Pi prefer to boot from the USB first, or you want to save the split millisecond it spends checking for an SD card, read on.

Changes made to the OTP bit cannot be undone. Be absolutely sure that you want to do this. This is not necessary to boot from USB, this just makes the Pi check the USB drive first.

There is no way to make the Pi check the USB device first, it will always check the SD card followed by the USB.

These instructions are abbreviated from this guide and assume you're running Raspberry Pi OS on the device (though it should work with Batocera running as well).

  1. Add the line program_usb_boot_mode=1 to your /boot/config.txt on the SD card and boot your Pi.
    1. To do this in an amazing one-liner: echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt
  2. Once booted, you can check that the correct bit has been set by running vcgencmd otp_dump | grep 17:. If the output is
    17:3020000a

    then you're all set to go.

  3. You can remove the program_usb_boot_mode=1 line from /boot/config.txt to prevent the bit from being set every boot (it only needs to be done once).
    1. To do this in an amazing one-liner: sudo sed -i 's/program_usb_boot_mode=1//g' /boot/config.txt

This is its default behavior. In fact, you'd have to go out of your way to make it check the SD card first.

  1. Boot up Raspberry Pi OS on the Pi 4/400 and access it via SSH or use its local terminal emulator (if you don't have Raspberry Pi OS or can't install it, use the below instructions instead).
  2. Upgrade your system by running sudo apt update, sudo apt full-upgrade and then reboot.
  3. Run sudo rpi-eeprom-update -a to update the EEPROM and reboot again.
  4. Run sudo raspi-config to open up the interactive configuration tool, navigate with the arrow keys and [Enter]. The raspi-config command line tool, should be familiar to Raspberry Pi users.
  5. Navigate to 6 Advanced optionsA6 Boot Order and choose “B2 USB Boot”.
  6. Confirm that the screen says “USB is default boot device” and exit the to the main menu with [Esc].
  7. Select <Finish>, you can use the [Tab] key. At the bottom right.
  8. Let it reboot.
  9. The Raspberry Pi 4/400 will now always check the USB first when booting. You can shut down Raspberry Pi OS and boot into Batocera on your USB.

These actions are reversible by selecting the SD card instead of the USB. The OTP bit will still be set, however.

An alternate way is by flashing your bootloader. You will need a spare SD-card to do it (its data will be wiped in the process!)

If the power is interrupted during this process (such as from using a non-official power supply) your Raspberry Pi might be bricked!

  1. Download the Raspberry Pi Imager and run it.
  2. Select Misc utility images under Operating System.
  3. Select Bootloader.
  4. Select the USB boot-mode.
  5. Select SD card and then Write.
  6. Insert the card into your Pi (without the USB drive) and boot it.
  7. Wait 10 seconds. The green activity LED will blink with a steady pattern and the HDMI display will be green on success.
  8. Power off the device.
  9. Remove the SD card and insert the USB drive.

Your Pi should now boot from the USB drive first.

The Argon One case offers the ability to use an SSD in its special compartment, which connects to the Raspberry Pi via USB. This USB-to-SATA connections seems to be a bit picky about what it will respond to, so some extra steps are required should you want to install Batocera onto an SSD connected via this method (for reference, booting Batocera off of an SD card still works completely fine, this is for only if you explicitly want Batocera to boot from the SSD).

This only works for standard SATA 3 SSDs. NVME and PCIe drives will not work.

  1. If already assembled, disassemble the case
  2. Download and run the latest Raspberry Pi OS on the Pi 4
  3. Open a terminal and type sudo nano /etc/default/rpi-eeprom-update
  4. Change the word critical to stable and save the file with [Ctrl] + [S]
  5. Then run sudo rpi-eeprom-update to update the EEPROM
  6. Continue the steps from 3 in the recommended way section above
  7. Turn off the Pi 4
  8. Flash Batocera to your intended SSD
  9. Reassemble the case with the SSD attached
  • boot_usb_rpi_only.txt
  • Last modified: 2 years ago
  • by atari