Boot Raspberry PI from a USB Stick

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.

24 thoughts on “Boot Raspberry PI from a USB Stick”

  1. Hi Jonathan,

    Thank you for this guide!
    If I boot my Raspberry Pi off an SD card, reallocate the partitions, and run it from the USB memory stick…

    Can I then unplug the SD card, and use it as an SD card reader?

    Thanks for your help!

    1. I bet you can try, but on next boot you’ll have to have an SD-card inside with the /boot partition or at least the file that looks for it on the USB-Stick.

      If you want an SD-Card reader I suppose the easiest thing is to hook up a cheap card reader to one of the USB-ports.

  2. Thanks for your reply- yes, I can carry another USB SD reader, but that adds bulk to my pockets. The smaller the better! I’m using the RPi like an AirStash, but one that shares USB to WiFi instead of SD to WiFi. I’ll let you know if I try it out successfully!

  3. I finally had time to try this tonight, and it seems like I’m halfway there.
    The Raspberry Pi begins to boot, and switches to the USB memory stick successfully!
    Unfortunately, I get permissions errors as the boot continues, and it can’t reach a shell prompt.
    The final error says that the USER environment variable isn’t set, which is obviously a result of the permissions problem.
    I’m using two SD cards; it becomes a USB memory stick for booting when plugged into a card reader. This is just to prove the concept.
    Both SD cards are already 2 GB, so I figured that I didn’t need to change anything in the 3rd guide. Is that right?
    Thanks for your advice!

  4. I have a 2 GB SD Card and 16 GB USB stick and got this working correctly after a few tries.

    This is what I did:
    1. On Windows format both your SD card and USB stick to FAT32. I did this through diskpart.
    2. Copy the Raspberry OS to the SD card. There are lots of tutorials out there for that.
    3. Hook up the SD card to the RPi, I left my USB stick out for a while.
    4. Hook up your keyboard and monitor. Start your RPi up.
    5. I selected to expand rootfs to the entire disk. Reboot.
    6. Hook up USB stick. Run lsusb to ensure it populates on that list.
    7. Assuming your USB stick is /dev/sda1 (usually is…) run: sudo dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=512
    This will copy all your SD card to your USB stick. This took me about 45 minutes to execute, so go cook dinner or something . :)
    8. After that is done, run: sudo nano /boot/cmdline.txt
    Change where it says root=/dev/mmcblk0p2 to /dev/sda1
    9. Next, run: sudo nano /etc/fstab
    Change /dev/mmcblk0p2 to /dev/sda1
    10. Reboot (sudo shutdown -r now). You should now be on your USB stick! Run df -h and you’ll be disappointed with the file size like I was >.<
    11. Run sudo resize2fs /dev/sda1
    This took about 30 minutes to finish executing.
    12. Restart if it doesn't automatically. Run df -h and see your full USB stick!

    1. Thanks! This is a great contribution, since it shows how you got it working on Windows, then booting to the raspberry pi, where I mainly copied stuff back and forth on my Mac with barely touching the Raspberry after boot.

  5. Thanks Jameson and Jonathan for the great info for shuffling partitions around. I was able to transfer a living partition from my SD card to an external USB HD and bring the whole thing back on line. Double plus thumbs up!

  6. thanx to Jameson and Jonathan for share your great info , but I used gparted to reformat mmcblk0p2 as swap partition on sdcard and it done ;-)

  7. I wanted to do this very same thing with an External USB HD while I got it to finally work. Their is still things you should note (think about) before doing so.

    I could only get this to work with an 5400 80gig HD (and a cheap Iocell enclosure) when using the power off the USB port (self powered USB HD’s will not have any issues like this but, the port isn’t putting the power out to keep spinning larger HDs) remember bigger space means more platters inside to spin. which ends up begging the question.. How much space do you really need (though over kill isn’t always bad)? my pi is specifically being used to back up one thing to its HD (currently) a live Minecraft server off a VPS (twice a day). Since I wanted something very low power that I could simply leave on 24/7 but couldn’t rely on SD cards (they tend to fail often because they where never designed to be used for this purpose/this often) I decided a HD was the right choice.

    Final setup Setup:
    RaspberryPi B-rev2
    Iocell laptop HD enclosure aka “i-portable”
    Seagate 5400 80 gig Momentus xt
    Boot SD is an extremely old 256meg nothing special card I had laying around (can’t even buy less then 2 gigs anymore and even those are rare) made by Sandisk.

    setup attempt #1 (this didn’t work):
    same as the final but with a WD Scorpio Blue HD (1TB) SATA2 power usage isn’t listed, but I suspect its much like the HD below!

    setup attempt #2 (still didn’t work):
    same as the final but with a Hitachi 5400 I suspect its SATA2 but can’t confirm (came out of the Apple Mac Mini mid 2011) and is labeled as needing 700mA and 5v (I should of looked at the label first (live and learn.. Read those labels kids)! because its requires more then the Pi will give it!

    My next attempt at such a thing will use a self powered USB HD using a 3.5 sized HD enclosure (how ever with a 2.5 HD inside most likely the 1TB) using a WD USB HD Enclosure, not because I need more space, but just to see if I can get the pie to fit in the case and have it in a professional looking case instead of zipped tied together (I have function working so why not get it to look better :P).

    you can see where I’m going with it in this image:


    when I get the new setup going I’ll most likely have it doing more then just backing up Minecraft. Maybe severing files or web server… I’ll figure that out later.

    1. Wow, you really put some effort into passing on your experience! Thank you so much! I’m really really happy that this post I just wrote because I ran into problems, sparked off such exchange of experiences!

    1. That’s pretty awesome! It’s not like the card space is expensive these days, but why bother if you can do with this!

    1. This is very unlikely to damage your hardware. What’s your issue? You can always format the card and put a stock image on it.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>