Boot Raspberry PI (2) from a USB Stick

Update: Works with the Raspberry PI 2

I have a tendency to get busy on stuff when I’m under pressure for some completely different stuff, in this case I’m fiddling with my Raspberry PI instead of writing my exam report. As it is the sixth of December, I received a little traditionally dependent gift from my mother. In Germany we celebrate Dec. 6th with a little present for kids. As of me being 23, that hasn’t changed I guess. The gift was greatly timed, since it’s a 32GB USB drive, which I directly plugged into my Raspberry PI to make the USB drive the root partition.


Make Raspberry PI with Raspbian boot from USB

You can’t do that. Well, you can make the operating system reside on any USB medium, but the actual /boot partition needs to stay on the SD card.

Luckily Linux and the Raspberry have a great community, so there are multiple guides how to do this. What I did was:

  1. Copy the debian image to the USB stick (guide)
  2. Change the cmdline.txt to load the OS from the USB stick (stackexchange thread)
  3. Grow the root filesystem to fill the USB drive (stackexchange thread)

The code in my cmdline.txt now:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda2 rootfstype=ext4 rootwait text 

You have to adjust some steps in the third guide, so it matches your setup and shift out some device names, also since the included script in the rasp-config tries to grow the sd card partition, even though the root partition is on a USB drive. At least that’s what I think it does, because it couldn’t grow my root file system, when it was on the USB drive already.

Since you’re deleting and re-applying a partition table while actually running the OS from it, I recommend that you backup any data on your Raspberry PI, if you have any. It’s quite a crazy thing to do, but it worked perfectly for me.

I hope this helped and it’s useful to somebody, because I just hacked my solution together from the three guides above. Let me know if it works for you too.

7 thoughts on “Boot Raspberry PI (2) from a USB Stick”

  1. Where can I find the cmdline.txt file?
    The thing is I’ve bought the raspberry pi 2 and I’ve only got 1GB memory card but I’ve got lots of spare USB sticks. So I’m stuck as I don’t have the raspberry pi set up yet…

    1. If you’ve installed an OS via NOOBS (generally recommended) then you can access it by holding down the SHIFT key on boot. Then, select your OS, and click the “Edit Config (e)” button. Click the cmdline.txt button at the top, and that’s it!

  2. Hi, I just wanted to point out a couple of things, while your guide does and will work fine with a single USB drive, it’s not the correct and safe way to mount drives in Linux and can have undesired results if you have multiple USB drives connected, Linux assigns the device ID based on the order it enumerated the USB devices, which means if you have multiple USB drives connected the one you want to boot from may not always get the ID /dev/sda2, the solution is to use UUID’s instead which are unique to the partition therefore will not have problems with multiple USB drives plugged in.

    I did a post on the OpenELEC forums on this very subject almost 2 years ago:

    Also I use this type of setup in my car with headrest monitors for kids entertainment, and let’s just say USB drives have a habbit of failing due to the many hard poweroff’s a day it goes through (at least 4 sometimes more), I’ve lost 2 32GB drives so far and am now implementing a UPS/shutdown setup to keep USB drives alive and file systems healthy!

Leave a Reply

Your email address will not be published. Required fields are marked *