Boot Your Pi Over USB

Historically, booting a Raspberry Pi required an SD card. However, if you follow [tynick’s] instructions, you can get a Pi 4 to boot from the USB port. Combine it with a small solid state disk drive, and you’ll get great performance, according to his post.

The caveat is this depends on a beta bootloader and, of course, you’ll still have to boot from an SD card at least once to load that bootloader. If you were deploying something serious, you’d probably want to make sure the bootloader is suitable for your needs.

In fact, most of the work here is doing the prep work. You have to grab the new bootloader and flash it. You also have to make some changes to get the boot code to check the USB port. You also install the operating system image on the SSD just like you would an SD card.

After that, it is easy to copy the boot files to the USB drive and you are ready to go. This would be a great use for an old SSD if you pair it with a USB adapter.

According to the post, the SSD is about ten times faster than the SD card, so the performance boost is significant. Of course, some of this depends on the USB adapter, and [tynick] recommends a particular one that seems to work well.

The Pi 4 is already fast, especially with a 64-bit OS. If you don’t like the SSD bootloader, you can do a similar trick to boot from the network.

49 thoughts on “Boot Your Pi Over USB

  1. It’d be interesting to know some actual measurements on boot times with a tiny image. At least when I did some tests with USB-SATA bridge vs SDCard on a tiny buildroot image, it seemed that the USB device would blink some LEDs quite a while before any boot texts appeared on the screen.

    Sure the software measured boot times could be shorter, but are they actually shorter when compared from power up.

  2. > If you don’t like the SSD bootloader
    If you don’t need the SD card reader you can also put /boot on the sd card and / on the ssd. That should work on a standard boot loader.

      1. Hardly obscured when the very first line in his article is “Before I go any further, I want to mention that this is the official solution from Raspberry Pi.”

    1. Pi’s have never been about fully open source. The Whole point is affordable SBC’s to lower the barriers to entry on electronics and computer science. The computer/phone you used to write that stupid comment probably has a propriety BIOS on it, just about everything does. Unless you have personally changed the BIOS to an open source alternative (which can be very involved if you don’t have already supported hardware) it will be – So the first thing loaded by your internet gadget isn’t free and could well be owned by Microsoft/Google/IBM etc as the big tech companies tend to hoover up littler ones anyway!

      If they fixed that next you would complain how dare they use a Broadcom Arm chip and Vidcore GPU.. I want my open source RISK chip!

      1. As you probably sont know zoobab,we’ll forgive you, bit chances are he IS using a complete libre solution tot write is correct statement ;)

        Andere I fully agree with him. There’s no point andere it is stad, that we boot propriatery blobs on the pi.

    2. Correct. But Broadcom, from whom the SoC is purchased, bought a licence to the entire ThreadX source (many years prior to its sale to MS), and in turn Raspberry Pi therefor have access to all the threadX source in perpetuity. So MS have no hold over it, have no input to it, and have had nothing to do with the source on which the firmware is based because the source is from well before MS bought ThreadX. You argument is a bit like buying a Ford car, then Ford being bought by Toyota, then saying you are now driving a Toyota. No, you are still driving a Ford.

    1. As this article says: you’d still need to run something on the Pi via the SD card (or a use the programming interface) before the bootloader would even look at a USB drive.

        1. Does anybody have soms technical insights on how this works? Do the toggle soms fuses/bits (like iMX6) or are the loading a tiny piece of code into some internal eeprom inside the SOC?

    2. Being the curious type that I am, this isn’t just the PI 4s… It applies to the PI 3 series as well, which makes me VERY happy. And that is per the official Raspberry PI site.

  3. Running some tests for my use-case:
    I run a miniDLNA server, motionEye hub, and BCM280 temp&pressure sensor on a 4B-4GB. With SDCard it was slow, and expensive. With USB3-boot thumb drive, and USB3 media HD (4TB), it’s found it’s niche. Very fast, and so far, very reliable.
    I was losing an SDCard a week or two. Logs, buffers, etc, kills SDCards, but the USB3-thumb drive just chugs along so far.

    1. As workaround, and to get something that is more really embedded than “classical linux distro on a SD card”, which, as you write, kills and SD very fast, i do the following:
      i have an optimised kernel that contains only what i want/need + an initrd image with my whole system in it.
      the rootfs is extended through unionfs with my ramdisk located r/w filesystem.
      That ramdisk is periodically gzipped and rotated as a file on the SD card.
      Voila, a very robust system that has now an uptime for >2 years although there are quite much read and writes, and uses a very cheapo SD card without destroying it.

      inspiration came from TinyCore Linux (piCore version)
      It´s flexible, extendable, rock solid.

      I never use that clutter of debian derivated raspberry pi OS.

      1. And that article title is plain wrong: it does not boot from USB. It boots from SD card a blod that chainloads the bootloader on the USB drive. Quite not the same !!!

  4. It’s cool that this can be done now. It’s also cool that someone wrote it up. Thanks for that!

    But what I don’t get though is it seems like this is THE feature that people have been demanding for a while now. Why?

    We could always throw just the kernel and /boot partition on the SD and put everything else wherever we wanted to so long as we either build the necessary drivers into the kernel directly or use an inittrd. That’s one of the really powerful things about Linux. Just try to run Windows on a small C:\ drive. It doesn’t matter how many other drives you have or where you tell it to install your software. The bulk always ends up in obscure subdirectories of c:\Windows.

    Anyway, back on topic. How many people write their kernel to disk so often that it kills an SD card? Are we all Linus Torvalds? Do we all pronounce Linux Linux? Or is it boot speed. I’m not on a Pi at the moment but all the kernel versions on my Desktop come in at less than 7MB. How long does it take to load 7MB off of an SD card?

    Oh well. I’m not complaining that we have a new feature to play with. The one I have really wanted though is a true SATA port. Something built into the chipset, not constricted by the bandwidth of a USB. Something like the old Banana Pis but with more RAM, more cores and a faster clock speed. Each Pi version without that was disappointing to me. But now it has USB3 which is almost as good. So I am happy! Maybe I will replace my Banana Pi file server with a Pi4 one of these days.

    I’ll probably keep the OS on the SD card though. I like a clean separation between software disk and data disk. I can always just copy the SD card for a backup before I put everything away.

    1. Lots of reasons to want to run off any other storage medium but SD cards. SD cards are pretty much garbage for everything but static storage. SD corruption is one of the biggest reasons people wanted to move off them, even if the SD card is still fine and just needs a new image written to it rather than actually dead its really annoying. And if you don’t take your Pi offline to image its SD card after tinkering with kernel/compiling applications etc all that work will have to be done again every time it corrupts on top of writing a fresh install (and if you are running a make on the Pi itself especially the early ones it can take a very very long time to finish – newer Pi’s are both faster and reported to be better at not corrupting the SD card but still). If you just have the boot partition on the SD card its not too bad to recover when its gone wonky again, but its not optimal.

      So being able to boot straight to the more durable and probably much faster disk is far better than needing an SD card with the boot partition. Giving your Pi a much higher chance of huge uptime without problems, and not needing to buy that extra SD card just to point to the OS.

      1. Ok. But that BananaPi I mentioned has been going something like four or five years now. It’s been long enough that I actually don’t remember. I am just now starting to see some errors in dmesg although I haven’t noticed any problems in operation.

        Reliability is kind of important for that device too because it lives in a rackmount case which lives in a rack that is a pain to service due to a rat’s nest of wires. The rack is in my furnace room which is in my basement, My in-laws live in the basement and go to bed really early. I do most of my projects at night. So physical access is kind of a pain. I would have switched away a long time ago if I was having problems with SD card corruption!

        I usually buy name brand SD cards, mostly from the local Best Buy on Black Friday so they aren’t so expensive. Maybe that helps.

        But hey, certainly not complaining. Every new feature is a good thing. I just don’t get why the SD card is such a big deal to so many people.

        Also, if you are recompiling your kernel, wouldn’t you do that in /usr/local? Wouldn’t that be on the hard drive? It’s not like all the building and linking take place in /boot. Just how many times would one have to copy a new kernel to /boot to use up the writes on an SD card?

        I wonder if people are running their Pis off of insufficient power supplies and then blaming the SD card when it corrupts. It’s hard to find a wallwart that really does a decent job. That would explain a lot. My file server Banana Pi lives in an old network switch chasis and uses the switch’s power supply. My Pi3 running Octopi used to give me the undervoltage warning all the time no matter what wall wart I threw at it. That was the only setup where I ever actually had to re-install due to SD card corruption. Last fall I wired it to the 3d printer itself which has a fairly nice ATX supply. Everything has been very nice since then.

    2. “But what I don’t get though is it seems like this is THE feature that people have been demanding for a while now. Why?”

      Because every other Pi’s been able to do it forever, it’s just the Pi 4 that hasn’t been able to do it. Some of the others still need an SD card to load bootcode for it, but that method doesn’t work for the Pi 4.

      Yeah, you can load a kernel on the SD card, load on the rest on the USB, but that’s not a “once and done” setup – you can’t unplug a USB stick containing the full OS and plug in a different one. You also can’t set the SD card into read-only mode to allow it to be fully static (at least not without ever being able to change the kernel).

      1. None of the other Raspberry Pi’s can boot directly from USB. The only options I’m aware of are 1) boot from SD card or 2) PXE boot from network. This is a completely new capability that will *only* work on the Pi4 because it because it requires new bootloader code. The Pi4 is the only Pi with an EEPROM allowing updates such as this to its bootloader.

        1. “None of the other Raspberry Pi’s can boot directly from USB. The only options I’m aware of are 1) boot from SD card ”

          Nope. It’s been possible to do a pure USB mass storage boot for a while now, although that eliminates the possibility of booting in USB device mode for the Pis that support it prior to the Pi 4. The Pi 4 has rewritable bootcode so the changes aren’t permanent for it.

          But it’s also been possible for every Pi *except* the Pi 4 to boot *through* the SD card, using a small bit of bootcode that’s read-only (so not much chance of SD card corruption), and load the operating system from there.

          You might say “that’s cheating, you could also just put the kernel and initramfs on the microSD card too!” but in that case the OS isn’t fully contained on the USB drive, so you’re not actually booting the OS from the USB drive. In the ‘boot through SD card to USB using bootcode.bin’ mode the OS *is* fully contained on the USB stick, so yes, you are booting the OS from the USB drive. bootcode.bin never has to change, the microSD card never has to be writable, it just sits there as a dumb helper.

          But even the bootcode.bin version didn’t work with the Pi 4. So before this there was *no* way to do it (definitely no ‘Pi Foundation’ way, maybe someone was able to get super-clever with chainloading or something, I have no idea).

          All of this information, by the way, is hidden away in the depths of the Internet, only able to be found.. as the top search result for “raspberry pi boot from USB.”

    3. maybe not fully on topic. But the first generation Tesla cars all have the same problem. They all run some linux from flash memory. Now it seems /var just gets destoyed by the immense amount of log writes it has to do. So no we are not Linus. But you can destroy memory not only in /boot. It really depends what you do with the distro …

  5. Keeping the kernel / initrd on a SD card and moving everything else to a hard disk was one of the first things I did when the rpi1 came out, at the time I was seeing if I could get gentoo to work on it
    surprisingly compiling your os on an SD card isn’t the best idea in the world.

    If this is booting directly off the hard disk without the need for an SD then kudos to the author

    1. The author has just rewritten the instructions that can be found on the Raspberry Pi forums – the kudos should go to the engineer who wrote the new bootloader code (not easy) and then the instructions on how to do it!

  6. Is there any info on the lifetime we can expect from a USB stick compared to a microsd?
    Just thinking about keeping it low cost (no SSD) as a USB 3 stick is comparable in price with a microsd, but much faster on the pi 4.

Leave a Reply

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