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!
How to boot your Raspberry Pi from a USB mass storage device
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.
Tip
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!
Comments (7)
I have a HDD from my old PC. I have put it in a shell and now use it like a USB mass storage (to retrieve old files) but have left it otherwise intact. Thus it should have Windows OS on it and I should be able to boot it from my Pi and run Windows, yes? I followed your instructions but when I go to boot from the USB nothing shows up on the display. My Pi turns on and I can hear the HDD running, but nothing else happens. It won't boot Windows. Am I missing something?
You cannot run Microsoft Windows on a Pi. There is Windows 10 IoT (Internet of Things) but it is NOT the Windows you know and (think you) love. In your searching you may come across Windows RT which IS designed for the the ARM processor but still has much higher requirements than our beloved little Pi has to offer and is not available to the public. Any other version is simply not designed/capable of loading for various reasons, least of which is the hardware. You CAN use a program called WINE (Wine Is Not an Emulator) along with additional software to allow you to run SOME Windows programs but the setup is not for the faint of heart and performance is that of machines produced decades ago.
Your best option is to purchase an external USB stick that you can set up to boot from but you are limited to the operating systems that have been developed or designed for the Pi. There are many to choose from besides the images provided by the Pi Foundation. Doing a search for BerryBoot or PINN may lead you to suitable alternatives if you are unhappy with Rasbian.
This will not work for two main reasons:
1. Your Windows installation is designed to run on a 32-bit or 64-bit processor (whichever your old PC was), not an ARM processor like the Raspberry Pi has. You can only run operating systems compiled for ARM processors.
2. Windows activates by hashing machine specs. You cannot transfer a Windows installation to any other computer easily because its activation will be invalid.
The Windows on that hard drive can only run on x86/x64 processors. Windows RT can only run on ARM processors. Pi has an ARM processor.
x86/x64 processors: They’re fast and powerful, but they require a lot of electricity. So, they’re used in desktop computers that can plug into the wall. All versions of Windows run on x86/x64.
ARM processors: They’re weak but low-power processors for smartphones and other devices that aren’t plugged into the wall. Mobile iOS, Android and Raspberry Pi run on ARM.
The two processor architectures are mutually exclusive.
So, if from boot from USB is enabled, and there is no USB drive plugged in (or no linux image on the USB drive) will it revert/fallback to boot from the SD card?
My question is because I want to make an IoT device, but don't want to be updating the packages individually, as they may break. So I only want to update the system as a whole. So I was thinking, the main image run on the SD card, but if a USB device is plugged in, then it can boot from that (assuming it has an upgraded image on it), it will then upgrade the SD card image from the USB image and reboot. Assuming the usb drive isn't still plugged in, then hopefully it would boot from the SD card. Correct?
It works fine if I only have one USB drive attached when it boots. It doesn't work if I have two USB drives attached.
This works great until...
I add a second or third HDD or SDD to the hub and reboot.
How to add "steering" to the boot so it goes to the correct drive and then gets /etc/fstab to load the other drives with UUID references.
Thank you!