Install Raspbian on a USB Flash drive from MacOS or Linux

This guide will help you through the steps necessary to install Raspbian (current version at the time of writing, Raspbian Jesse) onto a USB Flash drive from MacOS (OS X) or Linux (ie Ubuntu). You will need a good quality USB Flash Drive, a USB MicroSD card and a Raspberry Pi (I’m using a Raspberry Pi 3 with WiFi).

Before we begin

This method of booting is experimental and won’t work with all USB Flash devices. I’ve tried this using a Raspberry Pi 3 and had success using both Corsair Voyager 3 and Toshiba Flash USB flash drives. Let me know your device and whether or not you succeeded in the comments.

Make your Raspberry Pi quicker and more reliable

The biggest benefit of using a USB flash drive is, they are far more reliable than MicroSD for running Raspbian and tend to be a lot quicker. It’s a cheap way of improving the performance of your Raspberry Pi.

Step 1 –  Download and install Raspbian image on the USB Flash and MicroSD

Visit the Raspbian website download page (Raspbian download page here) to download the image. I’m using Raspbian Jesse Lite as I don’t require the GUI but use Pixel if you wish. Once you’ve done that, insert your MicroSD card into the card reader on your computer.

Open a terminal window and type the following command if you’re using MacOS (inc OS X):

diskutil list

Or if you’re using a Linux machine (ie Ubuntu):

fdisk -l

You should see something similar to this (if you’re using MacOS/OS X):

We can see that the MicroSD device is located at /dev/disk1. This might vary on your machine. We need to unmount this using the following command in MacOS (inc OS X):

diskutil unmountDisk /dev/disk1

Or if you’re using Linux (ie Ubuntu), changing sdb1 for your MicroSD card:

sudo umount /dev/sdb1

Ok, next we need to copy the files from the image to the MicroSD card. I’m Make sure the Raspbian image is unzipped, I’m assuming that your Raspbian image is in your Downloads folder. Change directory to your downloads folder:

cd ~/Downloads

Next copy to the device using:

sudo dd bs=1m if=2017-04-10-raspbian-jessie-lite.img of=/dev/disk1

Remember to change the ‘2017-04-10-raspbian-jessie-lite.img’ filename to the actual filename of your Raspbian image. Also, remember to change ‘/dev/disk1’ to suit your machine.

After a while, the files will finish copying from the Raspbian Jesse image to the MicroSD card, you will see something like this:

Once this is done, eject the MicroSD card in MacOS (and OS X):

diskutil unmountDisk /dev/disk1

or if you’re in Ubuntu or similar:

sudo umount /dev/sdb1

Repeat step 1 but this time for the USB Flash Drive.

Step 2 – Prepare the Raspberry Pi

Next we need to insert the USB drive into the Raspberry Pi and boot it up. Once you’re booted and logged in, open the terminal window if you’re in the GUI and make sure you’re up-to-date using:

sudo apt-get update -y && sudo apt-get upgrade -y

Now we need to modify our config file to try and get our device to boot from USB Flash devices:

Next, edit the config file using this command:

sudo nano /boot/config.txt

Add the following line to the bottom of the file:

program_usb_boot_mode=1

Save and exit using CTRL + x. You will need to hit Y to confirm the changes.

Step 3 - Boot Raspbian from USB Flash drive

Now we need to insert our prepared USB flash drive into the Raspberry Pi. From the Raspberry Pi terminal, restart using:

sudo reboot

Once rebooted, from the terminal in the Raspberry Pi, type the following command:

vcgencmd otp_dump | grep 17

If you see 17:30200000a, the OTP has been successfully reconfigured. Shut down your Raspberry Pi:

sudo halt

Once the Raspberry Pi is completely shut down, remove the MicroSD leaving only the USB Flash drive. Reconnect the power and hopefully, the Raspberry Pi will restart from the USB Flash drive.

Conclusion

Booting from a quality USB Flash drive provides many benefits. They tend to be a lot quicker and more reliable than MicroSD cards. Let me know your thoughts and let me know if you got this working with your USB Flash devices. I will build a list of devices this works on over time.

Ste

Web Developer living in Manchester, working for Studio Skylab (http://www.studioskylab.com). Views and thoughts are my own.

You may also like...

17 Responses

  1. Rick Commo says:

    Steve, how badly does running the OS from a USB drive impact the overall USB bandwidth? Maybe said a little more quickly, how dies it impact networking and the like?

  2. Rick Commo says:

    “Maybe said a little more clearly, how does it impact…”

  3. A little confusing… shouldn’t the first line in step 2 be to insert and boot from the microsd?

  4. John says:

    you have to do ‘sudo fdisk -l’ to get anything useful on my system

  5. I wasn’t able to get this to work. After pulling the SD card and powering, it didn’t boot. I did get the older version of this tutorial to work though. (https://www.stewright.me/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/)

  6. I didn’t get this version to work. I will try the old version.

  7. CjH says:

    I have just got a Rpi3 Mod B. I am very new to Linux and can only do really basic stuff. I would like to boot from USB HHD or Flash Drive.

    I have read a lot of posts about this process and it still seems very hit and miss. For someone starting out like I am , is it a good idea go try this?

    I have managed to set the OTP bit (checked with otp_dump and get 300002a). I can attach HHD or Flash Drive to powered usb hub and mount them etc.

    So all that is left is for me to get clear in my head :

    correct version of Raspian to use (i am using unzip of Noobs June 2017 which I downloaded and unzipped to new 32GB SD on Windows Laptop – install Debian when I booted Rpi3 – all all seems fine (i installed cups etc. and wireless printer. VC . Filezilla on Windows can read/transfer files to /from Rpi3.

    So now to USB booting – It seems that a lot of confusion exists about the following:

    What is the best format for the Flash Drive / HDD?

    What version of the O/S i should use on Flash Drive /HDD ( can i just use etcher to copy contents from existing booting SD to Flash Drive or HDD. on my windows laptop.

    There seems to be a lot of discussion as to what should be already on the Flash Drive /HDD (system stuff , typeof format etc) before copying. No real “this will work most of the time” instructions.

    Once HDD or Flash Drive are set up what are the exact sequence of booting, rebooting, removing the SD? What can and cannot be attached at boot time (both SD and USB device or just SD). Guess I don’t understand the boot sequence. If the SD is not present how are drivers etc for USB started up?

    As the OTP bit is set can I just attach the USD device with O/S installed , and boot without the SD.?

    Does booting from the USB still stop wireless working or is this fixed.?

    I am sorry to be so long winded but Its all very confusing for someone starting out and any clarity would be most welcome.
    Thanks

    • Ste says:

      I’d say a decent USB flash is sufficient, plus you don’t need to take up another power socket with an external HDD (2.5″ ones would draw too much power for a RPi alone to power). If you want to fast track, send me your details and I’ll send you a flash drive that’s already provisioned to boot.

      Ste

  8. CjH says:

    Thanks for reply and offer. I live in Dublin so there would be postage etc. I will reread as you suggest and then maybe try this.

  9. Rob Welch says:

    Thanks for posting this; I’m eager to give it a try. Could you post links to Amazon pages for the USB drives that are known to you to work? I tried copying/pasting the names of the USB drives you mention and I came up with all kinds of stuff, none of which was an exact match. Thanks!

  10. Rob Welch says:

    This seems not to be working for me. I’ve completed all the steps but Pi still seems to be looking for MicroSD card. I’m using 2017-09-17-raspbian-stretch-lite.img and SanDisk USB 3.0 128 GB. I’ve definitely set program_usb_boot_mode=1 in /boot/config.txt
    Nevertheless, when I remove USB and re-insert microSD my pi boots up just fine.

  11. Marc Draco says:

    Works fine with Rasbpian on later model Pi3s (most of them actually) but it won’t work with ALL operating systems.

    As an example. Peach osi (https://peachosi.com/) which is XFCE (but not as we know it captain) need to be booted from a micro-SD – you can hand-off to a USB mount on /dev/sd2 per the original method though.

    Also, Peach Osi is based on Ubuntu 16.04 LTS and looks pretty sweet for a low-power daily driver.

  12. CjH says:

    Just an update on my October post/comments. Using Stretch version of o/s it was possible to interrupt the boot from sd card (hold shift key down) and then I was given the choice where I wanted to to install the os. I selected USB (upgraded to SanDisk 32GB as suggested) and the os installed. I removed the sd and rebooted Raspberry Pi 3 Model B. Booted no problems from USB and still going strong. Thanks for the help.

  1. 23rd June 2017

    […] by Ste · 20th May 2013 Important information This tutorial is out-dated and has been updated here: Install Raspbian from USB Flash drive […]

  2. 6th August 2017

    […] level you go with. I’m going to assume that you’ve followed my previous tutorial on how to install and run Raspbian OS from a USB Flash Drive, although this isn’t […]

  3. 6th August 2017

    […] configuration (see RAID tutorial) and have my Raspbian OS booting from another USB Flash Drive (see tutorial on booting from USB) so there is a little bottlenecking on the USB bus, but for general usage, it’s not a concern […]

Leave a Reply