The firmware included with the Raspberry Pi 2 Model B version 1.2 introduced the possibility of booting from a USB device: before that, it was only possible to boot from an SD or microSD card. But that capability wasn't widely known or used on the Pi 2 or Pi 3. In my opinion there were two major reasons for this:
- USB boot was not activated by default, and activating it was a bit complicated, or at least tedious
- The Pi 2 and Pi 3 only had USB 2.0, which meant that USB devices were even slower than the SD card
The Raspberry Pi 4, however, has fixed both of those problems. USB boot is enabled by default, and the Pi 4 has two USB 3.0 ports which make USB mass storage devices noticeably faster than SD cards. So, in theory, USB boot should be gaining in popularity, but it seems to me that is not happening. Perhaps it is because of a lack of familiarity with the possibility, or a lack of detailed examples of doing it. So I will run through various aspects and examples of it in this post.
SEE: Hiring Kit: Python developer (TechRepublic Premium)
The first question to ask, I suppose, would be why is USB boot interesting at all? Well, one good reason I have already mentioned is that a USB 3.0 device is faster than an SD card. Another is that USB drives tend to cost less than microSD cards of the same size, and as the storage capacity goes up, the price difference gets larger. The reason I have gotten into this, however, is that I recently got a Raspberry Pi 4 case which includes an M.2 SSD adapter, and that drive connects via USB. (I will be writing about that case in my next post.)
First, as I just said, USB boot is enabled by default on the Pi 4B (and the Pi 400, by the way), but there is a small caveat to that. It seems that some early bootloader firmware versions did not properly support this, so you have to be sure that your Raspberry Pi 4 has bootloader eeprom firmware dated Sep 3 2020 or later. There are two ways to do this; either remove the microSD card and then boot, so you can read the firmware date from the diagnostic screen, or simply run vcgencmd bootloader_version. I have three Pi 4 units (with 1GB, 2GB and 4GB of memory) which I got from the first batch available in Switzerland, and all of them have Sep 3 firmware so I assume the older firmware is not very common. If you happen to have an older version, the instructions for updating are given in the USB mass storage boot section of the Raspberry Pi Hardware Documentation.
The other requirement for USB boot is that you have to be booting Raspberry Pi OS version 2020-08-20 or later. In practical terms this simply means that you should use the latest Raspberry Pi OS image from the downloads page (which currently is 2020-12-02), or if you are going to copy an existing SD card check the contents of /etc/rpi-issue. I am not going to get into a discussion of booting other Linux distributions at this point, because I haven't had time to try it out myself yet.
Creating a bootable USB device is very simple. If you already have a Raspberry Pi 4 running, you can either clone the existing SD drive, or you can use the Raspberry Pi Imager to download and copy the latest version to the USB drive.
First, and very important, make sure that you have a USB 3 drive (duh)! You could use a USB 2 device, but you would almost certainly not be pleased with the performance when you booted it. Also, I would suggest using a "nano" form device because not only does that look better, it is less likely to be knocked loose or damaged than having big old USB stick hanging off the end of your Raspberry Pi. Finally, make sure that you have the drive plugged into a USB 3 port (one of the two which have a blue tab, not a black tab).
Cloning an existing SD card can be a good option if you already have a system setup and configured, with additional packages and applications installed. To do this, go to the desktop menu, Accessories, SD Card Copier. The utility will identify any SD and USB drives currently connected, and you can choose the From/To devices appropriately. The utility will try to adjust for different sizes of drives, but I would suggest that you check the partitions on the USB device after it has finished to be sure you are happy with whatever it did.
The alternative, creating a USB drive with a freshly installed image, has the advantage of being sure that you are using the latest distribution release, and may give you more control and flexibility in partitioning. But the disadvantage is that you will have to go through the first-time boot process, including system configuration, installing the latest updates, and possibly installing and configuring whatever additional packages and applications you may need or want.
To create a fresh drive, you will first have to download the imager (it is not included in the base PiOS distribution):
sudo apt install rpi-imager
Then go to the desktop menu, Accessories, Imager. There are just a couple of things to watch out for in this utility. Most important, in the Operating System selection the Raspberry Pi OS which comes up in the main list is the "basic with desktop" version. If you want the "full" version with all of the recommended software installed, or the "Lite" version with only CLI (no GUI desktop), you have to select that from the list under Raspberry Pi OS (other). The USB disk will show up in the SD Card selection – and it won't offer to overwrite your existing SD card, so the USB drive is likely to be the only thing listed there.
The other alternative for creating a bootable USB drive is to do it on another computer, in pretty much the same way that I have described creating a bootable SD card in previous posts. Get the image from the Raspberry Pi Downloads page, and copy it to the USB drive. There is nothing special that needs to be done differently from the usual SD procedure.
Once the bootable USB drive has been created, all you need to do is shut down the Raspberry Pi 4, remove the microSD card, and plug in the USB drive. When you power up the Pi 4 again it should boot from USB, and you should be able to tell the difference in speed both for the boot process itself, and when starting programs and applications.
So, that's the basic process. Based on my experience so far, you can have an existing Raspberry Pi 4 or 400 booting and running from a USB drive in less than 30 minutes. Now, for a look at some of the more fun/interesting technical bits!
The "official" details about USB booting are in the Raspberry Pi Hardware documentation, under USB mass storage boot. There is some additional technical detail under USB as well. There is also a page with some very interesting details specifically about the Raspberry Pi 4 bootloader.
The Raspberry Pi 4 (and 400) bootloader firmware actually knows how to boot from either USB or the Network in addition to the SD card. The raspi-config utility lets you make a simple selection between these two as a secondary boot device when an SD card is not present. This is a bit odd, because raspi-config is a command-line (CLI) utility, and this selection hasn't been added to the GUI Raspberry Pi Configuration utility. I have to wonder why not, but anyway... to run raspi-config you first start a terminal window, then run sudo raspi-config, to get the initial screen shown here. From this screen choose Advanced Options and then Boot Order.
In my opinion, the Boot Order screen is rather poorly named. You can't actually do much with the boot order here, because the SD card will always be tried first, and you can only specify either USB or Network boot to follow that, but not both. If you're up to a bit of command-line work, there are a lot more possibilities available via the rpi-eeprom-config utility, which is described in detail on the Raspberry Pi 4 bootloader page.
There is one more potentially confusing thing about updating the eeprom configuration, using either raspi-config or rpi-eeprom-config, which I want to explain.
Any changes you make have not yet been applied when you save and exit from the utility. They have been saved to the /boot directory on the disk, so you have to reboot that disk in order for the eeprom to actually be updated. If you don't, for example, if you change the value but then shut down, remove the SD card and boot from a USB drive, the eeprom will not be changed. I know this sounds like an obscure case, but it bit me while I was working on this, so if/when it bites you, remember that I told you so.