Pi SSD

USB Boot

Requirements

For this tutorial there is a minimum required components.

Recommended

  • Raspberry Pi (preferably a 3 or up)
  • Micro SD Card
  • Power Supply
  • Ethernet cable
  • USB Storage Device

Optional

  • Raspberry Pi Case
  • USB Keyboard
  • USB Mouse
  • USB SD Card Reader

Setting up the Raspberry Pi for USB Booting

Before you start lets make sure that you use a Raspberry Pi 3B, 3B+, 3A+ or a Raspberry Pi 2B v1.2 or the newer Raspberry Pi 4. Other models of the Raspberry Pi do not properly support USB boot.

If you have a Raspberry Pi 3B+ or a Raspberry Pi 4, you can skip to the next section of the tutorial as the USB boot bits are already set within the one-time programmable (OTP) memory on the device.

To begin this part of the guide, you will need to start off with an SD card with Raspbian installed. For the purposes of this guide, you can just use Raspbian Lite as we only need the command line.

Once you have your Raspberry Pi booted up into the Raspbian operating system go ahead and enter the following commands into the terminal. These commands will ensure that the Raspberry Pi is entirely up to date and has all the features that we require.

sudo apt update
sudo apt upgrade
Update the Pi

Now that our raspberry pi OS up to date is, we can now enter the following command into the terminal. This command writes the text program_usb_boot_mode=1 to the boot configuration file so that when the Raspberry Pi boots up, it knows that it needs to write data to the OTP for USB boot mode.

echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt

With the correct data added to the /boot/config.txt file we need to restart the Raspberry Pi by running the following command.

sudo reboot

Once the Raspberry Pi has finished rebooting, we can verify that the OTP has been written to by running the following command. We utilize the Raspberry Pi’s vgencmd tool to provide a dump of the OTP, and from the result of this, we use grep to see if the text 17: can be found within the returned data.

vcgencmd otp_dump | grep 17:

If everything has worked correctly, you should see the following text appear in your command line from the previous command.

17:3020000a

Now before we go and move onto setting up our USB with Raspbian, we will remove the line that we added earlier to the config file by running the following command.

sudo sed -i 's/program_usb_boot_mode=1//g' /boot/config.txt
Raspberry Pi SSD

Booting the Raspberry Pi from a USB

Setting up a USB for your Raspberry Pi is extremely simple to do, and it’s just like installing Raspbian to an SD Card, instead of selecting your SD Card reader you will choose the USB storage device that you want to format. Insert your USB drive in a USB port of your PC and use your pi programming tool (see our sd creation) for writing the Raspberry Pi OS to the USB drive.

You should now be able to start up your Raspberry Pi without having an SD card placed in it. The Raspberry Pi should automatically utilize your USB as the boot device.

Please note that it can take the Raspberry Pi ten to twenty seconds for it to pick up the USB device and begin the process of booting from it, so don’t be alarmed if you have longer boot times.

I hope this Raspberry Pi boot from USB tutorial has shown you how easy it is to set up your Raspberry Pi so that it can boot the operating system from a USB storage device instead of the Micro SD Card.

Leave a reply:

Your email address will not be published.

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