Look, ma, no SD! Boot a Raspberry Pi from USB only

The Raspberry Pi 4 is now capable of booting from a USB Flash drive without requiring an SD card to kick-start the process. Here’s how you set it up.

USB disk, yes (left) — SD card, no (right)

If you’ve read my post on booting from a USB stick, you’ll know that this is a big step forward. While you could previously use a USB disk as your primary Pi storage, you still needed to have an SD card fitted too.

No longer. Changes made to Raspberry Pi OS back in August and to the bootloader code stored in the Pi’s EEPRom mean that you can boot a Pi 4 straight from the USB stick, though you’ll need to start out with an SD card because that’s the default.

Here’s what I did to try it out. I’ve included all the steps I took, but you may want to modify the procedure slightly if, for example, you want to copy your existing storage to the stick. You can find out how to do that in my previous post.

  1. Write Raspberry Pi OS to your USB disk. I used the steps below; you might want to try Raspberry Pi OS Imager.
    1. Plug the USB disk into your computer.
    2. Determine the USB’s file name, eg. disktuil list on a Mac.
    3. Download the OS and unzip it to get the .img file. I usually rename it to pi.img to make the next step easier.
    4. Write the .img to the stick, eg. sudo dd if=pi.img of=/dev/rdisk2 bs=1m
    5. When it’s done, eject the drive.
  2. Boot your Pi as normal.
  3. Plug in the USB disk.
  4. Do the usual sudo apt update && sudo apt upgrade -y to make sure your OS is up to date.
  5. Enter rpi-eeprom-config. If this fails, your OS is not up date.
  6. Look for the line beginning with BOOT_ORDER. This setting controls how the bootloader moves through devices in search of a usable OS. It will probably say BOOT_ORDER=0x01. The 0x01 is the code for ‘attempt to boot from the SD card’. We need to change this to include the USB disk code, 0x04.
  7. Run sudo -E rpi-eeprom-config --edit to open the settings file in your text editor.
  8. Change the BOOT_ORDER code to 0x41 — ie. so that the line reads BOOT_ORDER=0x41 — in order to add USB booting to SD. I suggest keeping SD boot in case you need to switch back at any time.
  9. Quit your text editor and save the changes.
  10. I did a reboot and then shutdown the Pi before I removed my SD card, but you should be able to just shut down, remove the card and restart.
  11. The Pi will now boot from the USB drive and go through the usual disk resizing and desktop setup wizard.
  12. You can re-insert your SD card and copy data files from the newly inserted removable drive to the USB disk. Look in the rootfs folder for your previous home folder, eg. rootfs/home/pi.
  13. Eject the SD card safe as a back-up.

At this point you have a new OS install, so you’ll need to reinstall any apps that you want to use, Git repos that you have cloned and so forth. For me, it’s easier to start from scratch, but you might prefer to mass-copy across content from your SD card or a previous USB disk.

If you do, there are some potential gotchas. Here’s one: my previous UBS storage lacks a /boot directory because that’s on the SD card, but the new stick does have it. And don’t forget that it’s a separate, FAT32 partition, not a simple directory. You’ll need to add this partition if you want to start the boot process from the USB disk.

It’s easy when copying large volumes of files using a tool like rsync to get overwrite files that you shouldn’t. Be very careful.

Don’t forget though that once you have the files you want on your USB disk, you can take an image of it using dd as a back-up, just as you may have done with your SD card.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s