Saturday, March 16, 2019

Can Raspberry Pi boot from USB flash drive? And about how to do it guide.

Simple answer is 'yes, it can' but read on....
Or skip to the "So I will write summary first:" below.
Or skip to the "Raspberry Pi 3 B+ support USB boot.  How about Pi Zero W? Or other Pi?" below.


Not everyone is beginner, I think.

When people looking for how to guide for installing the OS(operating system), they were probably beginner or very first time trying to use Raspberry Pi. If that's the case, step by step guide might be very good choice.

But even so, it is better to explain general concept, I think.

If someone already knew some computer stuff, he or she probably doesn't need that step by step guide. Because Raspberry Pi is computer that means it is same concept.
For example, someone is Windows user like me and some Windows user knew if computer--motherboard support USB booting, Windows user can simply go to the CMOS setting and do boot from the USB stick.
So I'm thinking Raspberry Pi is computer so it might support USB boot, too.

So I'd like to know whether Raspberry Pi support USB boot or not. Or I might have to do something to get USB boot.
That's what I want to know, right?



So I will write summary first:


BCM2837-based Raspberry Pis which were all the Pi 3 models include compute module 3 and Pi 2 Model B v1.2, support USB host and Ethernet boot.

So if you have any of models with BCM2837, you can follow any general install OS guide (and install to the USB flash memory stick) which you might already knew.

And if you have other models include Pi Zero and Zero W, you need single file on your micro sd card and then it will boot from USB memory stick. So you can boot from USB memory stick and also need micro sd card with single file which I will explain below.



thought about boot from SD and then USB.

I am currently using the multiboot via berryboot.

And sometimes, I felt berryboot wasn't enough what I am trying to do. So I am thinking about like that.
3 or 4 OS on SD card and then 1 or 2 OS from USB flash memory.


So I was googling about it like this:
how do i install raspbian on usb memory


And I clicked below guide:

And read this part:
Important information
This tutorial is out-dated and has been updated here: ....
So I did clicked link which is below guide:

I have a Linux machine but most of my data--Raspberry Pi image file and etc, was on Windows which is my main computer.
So I clicked Windows version tutorial--below link.


I appreciate the detail guides. But when I am trying go through this guide it made me very confusing.
See this "Step 2 – Install Raspbian to the micro sd card"
And then "Note: If you’re using a Raspberry Pi 3+, you don’t need to do step 2. Jump straight to step 3."

"Step 3 – Install Raspbian to the USB Flash Drive"
The process is exactly the same as step 2, but this time we choose the USB flash drive as.....

And here--"If you're using a Raspberry Pi 3 Model B+, you can skip step 4."

"Step 4 – Prepare the Raspberry Pi for boot from USB"

"Step 5 – Boot Raspbian from USB Flash Drive"


Huh?
I realised that it is exactly same step as install Raspbian on micro sd card.

I have Raspberry Pi 3 B+ and Pi Zero W. So I already knew how to installing any OS on micro sd card.


As you can see, it took very long time to figure out.
Unfortunately, I clicked very old guide--May 2013. That probably is the reason though.



Raspberry Pi 3 B+ support USB boot. How about Pi Zero W? Or other Pi?

I am thinking newer Pi can support boot from USB memory stick but how about Raspberry Pi Zero W which I also have.

So I googling about it and found this:


This question already reveal how to do the booting from USB stick.

Quoted from the question.
The older Raspberry Pi's (Pi 1, Pi 2 and Pi Zero) couldn't boot from a USB-device, but the Raspberry Pi 3 has support for it. The Pi and Pi 2 have semi-support for it (using an SD-card with a single bootfile).

So if I wanted to boot from USB stick in Pi 1 and 2, I can place single bootfile--which I don't know it yet.

And other people answered that Pi Zero W use older chip like Pi 1 and 2.

And then I found someone wrote about that single bootfile--bootcode.bin.
And pointed to the source:
Special bootcode.bin-only boot mode section in Raspberry Pi boot modes - raspberrypi/documentation
Quoted from above link:
USB host and Ethernet boot can be performed by BCM2837-based Raspberry Pis (these are all Pi 3 models, and some Pi 2Bs). In addition, all Raspberry Pi models can use a new bootcode.bin-only method to enable USB host and Ethernet booting.

Just format an SD card as FAT32 and copy on the latest bootcode.bin.

This is useful for the Raspberry Pi 1, 2, and Zero models, which are based on the BCM2835 and BCM2836 devices, and in situations where a Pi 3 fails to boot (the latest bootcode.bin includes additional bugfixes for the Pi 3, compared to the boot code burned into the BCM2837).

If you have a problem with a mass storage device still not working even with this bootcode.bin, then please add a new file 'timeout' to the SD card. This should extend the time it waits for the mass storage device to initialise to six seconds.

I'm not 100% for sure yet. But if Raspberry Pi use BCM2837, USB host and Ethernet boot will support.

And I found all the Raspberry Pi specifications from Raspberry Pi - Wikipedia.
Screenshot of Wikipedia's Raspberry Pi Specifications section.
And as you can see, Pi 2 Model B v1.2 uses BCM2837. And all the Pi 3--3 Model A+, 3 Model B, B+ and Compute Model 3, lite, 3+.


So if you have Pi 2 Model B with v1.2, Pi 3 series and Compute Model 3 series, you can just install any OS on USB stick and remove micro SD card.

If you have other version include Pi Zero W, you can format the micro SD card and copy the bootcode.bin file.


Yes, I haven't tried it yet. But I think those are from the Raspberry Pi's official repository.
So I'm sure it will work.



Kali and Raspbian booted from USB flash drive.

I probably have to get more information about it so I just found this:
quoted from above link:
HawaiianPi wrote:
The Pi3 will check for a boot SD card first, before booting from a USB device. If no boot SD card is found in 5 seconds, then it looks for a boot USB device.

I think this is quite similar process as USB boot in PC--desktop and laptop computer.

When I read from above link, someone said some USB disk won't work. And I wasn't sure about it--If it's FAT32, why it shouldn't be.

But first I tried with quite old 8GB USB stick, it didn't work--Pi 3 B+ without micro SD card and Pi Zero W with single file on micro SD card.
So I thought I need to do something.

And I realised this could be compatibility issue. So I put my kind of new memory card read which can read SDXC format card, too.

Tada!


As you can see that micro sd card slot is empty.
Kali lite booted from USB Flash memory stick in Raspberry Pi 3 B+.
That USB memory stick doesn't work with USB boot--I tried like 2+ os and also with Pi Zero W.


This time, I tried same USB memory card reader with Pi Zero W. And it worked well.
And I had to put single file in micro sd card.
Raspbian stretch booted from USB Flash memory stick in Raspberry Pi Zero W.

If you'd like to connect more than two USB stick, portable hard disk or SSD, things became quite complicated. Because Raspberry Pi doesn't know which USB drive to boot from.

So you have to search more about it.


I hope you did learn about the basic concept or process of USB boot in Raspberry Pi.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.