By default, the Raspberry Pi boots from a microSD card. But since the release of the Raspberry Pi 3, new Pis have been able to boot from a USB mass storage device as well. Making that happen is a pretty easy thing to do, and it’s the subject of this how-to.
A word of warning: the new boot mode is in its experimental stage, so it might not work with your USB stick or hard drive. According to the Raspberry Pi Foundation, a couple of non-working examples are the Kingston DataTraveler 100 G3 32 GB and the Verbatim PinStripe 64 GB. The USB compatibility issue will only affect some of us, but the next warning is relevant to us all: setting the boot mode is permanent. With that said, this sounds much scarier than it is: your Pi will still boot preferentially from the microSD card, if one is plugged in.
With those warnings out of the way, let’s move on to the project!
Step 1: Install and update Raspbian
We’re going to end this tutorial by booting to Raspbian from a USB drive. But we can’t do that until we enable USB boot mode, and we actually need Raspbian in order to do that. The only way to boot to Raspbian right now is to put it on a microSD card, so, ironically enough, this how-to on booting from USB begins with us booting from a microSD card!
If you don’t have Raspbian installed yet, you can check out our easy guide on how to install Raspbian on the Raspberry Pi.
After installing Raspbian, let’s install possible updates:
sudo apt-get update sudo apt-get upgrade
Now that we’re up to date, let’s move on.
Step 2: Enable USB boot mode
Now that we have Raspbian on a microSD card, we can enable the Raspberry Pi’s USB boot mode. First, we’ll have to add a config option, and then we’ll have to reboot the Pi. This will set a bit in the Raspberry Pi’s OTP (One Time Programmable) memory, allowing the device to be booted from a USB mass storage device. After that, we won’t need the SD card anymore.
Enabling USB boot mode is easy. Open Terminal and run the following command:
echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt
This adds the config option program_usb_boot_mode=1 to the end of /boot/config.txt. Now let’s reboot the Pi. You can use the PIXEL user interface or enter the sudo reboot command in Terminal.
After the reboot, check that boot mode has been enabled with this command:
vcgencmd otp_dump | grep 17
The output should contain the value 3020000a.
If you are going to use your microSD card with a different Raspberry Pi later on, you might want to remove the program_usb_boot_mode=1 line from config.txt, so that the boot mode won’t be programmed to that device as well. You can edit the file using the command sudo nano /boot/config.txt.
Step 3: Prepare your USB mass storage device
This time we are going to install Raspbian on our USB device. The process is similar to installing Raspbian on a microSD card, so you can use the same instructions. Just substitute “microSD card” for “USB device” as you read.
Step 4: Boot your Raspberry Pi from the prepared USB mass storage device
Let’s plug in our prepared USB device and boot. After about 5–10 seconds, the Raspberry Pi should boot normally and you should see its rainbow screen. We’re back in Raspbian, only this time we’ve booted from the USB drive!