You are on page 1of 6

JonathanMH JonathanMH

Boot Raspberry PI from a USB Stick


I have a tendency to get busy on stuff when Im under pressure for some completely different stuff, in this case Im fiddling I have a tendency to get busy on stuff when Im under pressure for some completely different stuff, in this case Im fiddling
with my Raspberry PI instead of writing my exam report. with my Raspberry PI instead of writing my exam report. As it is the sixth of December, I received a little traditionally 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 dependent gift from my mother. In Germany we celebrate Dec. 6th with a little present for kids. As of me being 23, that
hasnt changed I guess. The gift was greatly timed, since its a 32GB USB drive, which I directly plugged into my Raspberry hasnt changed I guess. The gift was greatly timed, since its a 32GB USB drive, which I directly plugged into my Raspberry
PI to make the USB drive the root partition. PI to make the USB drive the root partition.
Make Raspberry PI with Raspbian boot from
USB
You cant do that. Well, you can make the operating system reside on any USB medium, but the actual /boot partition You cant 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. 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: 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: 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 t
ext
You have to adjust some steps in the third guide, so it matches your setup and shift out some device names, also since the 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 included script in the rasp-config tries to grow the sd card partition, even though the root partition is on a USB drive. At
Work Work Blog Blog About About
Boot Raspberry PI from a USB Stick - JonathanMH 12/11/2013
http://jonathanmh.com/boot-raspberry-pi-from-a-usb-stick/ 1 / 6
least thats what I think it does, because it couldnt grow my root file system, when it was on the USB drive already. least thats what I think it does, because it couldnt grow my root file system, when it was on the USB drive already.
Since youre deleting and re-applying a partition table while actually running the OS from it, I recommend that you backup Since youre 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. Its quite a crazy thing to do, but it worked perfectly for me. any data on your Raspberry PI, if you have any. Its quite a crazy thing to do, but it worked perfectly for me.
I hope this helped and its useful to somebody, because I just hacked my solution together from the three guides above. I hope this helped and its useful to somebody, because I just hacked my solution together from the three guides above.
Let me know if it works for you too. Let me know if it works for you too.
tags: debian, Linux, Raspberry PI, Raspbian
06. December 2012 - 11:44
by: Jonathan
in: code
Comment Comment
21 Responses to Boot Raspberry PI from a USB Stick
1. Peter Burkimsher says:
January 23, 2013 at 23:43
Hi Jonathan, Hi Jonathan,
Thank you for this guide! 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 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? Can I then unplug the SD card, and use it as an SD card reader?
Thanks for your help! Thanks for your help!
Peter Peter
Reply
Jonathan says:
January 24, 2013 at 11:57
I bet you can try, but on next boot youll have to have an SD-card inside with the /boot partition or at least the file that I bet you can try, but on next boot youll have to have an SD-card inside with the /boot partition or at least the file that
looks for it on the USB-Stick. 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. 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.
Reply
2. Peter Burkimsher says:
January 24, 2013 at 19:09
Thanks for your reply- yes, I can carry another USB SD reader, but that adds bulk to my pockets. The smaller the better! Thanks for your reply- yes, I can carry another USB SD reader, but that adds bulk to my pockets. The smaller the better!
Im using the RPi like an AirStash, but one that shares USB to WiFi instead of SD to WiFi. Ill let you know if I try it out Im using the RPi like an AirStash, but one that shares USB to WiFi instead of SD to WiFi. Ill let you know if I try it out
successfully! successfully!
Reply
Jonathan says:
January 24, 2013 at 19:11
Sounds great! Wishing you success on this! Sounds great! Wishing you success on this!
Reply
3. Peter Burkimsher says:
January 27, 2013 at 01:55
I finally had time to try this tonight, and it seems like Im halfway there. I finally had time to try this tonight, and it seems like Im halfway there.
The Raspberry Pi begins to boot, and switches to the USB memory stick successfully! 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 cant reach a shell prompt. Unfortunately, I get permissions errors as the boot continues, and it cant reach a shell prompt.
The final error says that the USER environment variable isnt set, which is obviously a result of the permissions problem. The final error says that the USER environment variable isnt set, which is obviously a result of the permissions problem.
Im using two SD cards; it becomes a USB memory stick for booting when plugged into a card reader. This is just to prove Im 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. the concept.
Both SD cards are already 2 GB, so I figured that I didnt need to change anything in the 3rd guide. Is that right? Both SD cards are already 2 GB, so I figured that I didnt need to change anything in the 3rd guide. Is that right?
Boot Raspberry PI from a USB Stick - JonathanMH 12/11/2013
http://jonathanmh.com/boot-raspberry-pi-from-a-usb-stick/ 2 / 6
Thanks for your advice! Thanks for your advice!
Reply
Jonathan says:
January 28, 2013 at 18:39
According to the thread, no. Admittedly, Ive only tried with a 4 gig card though. According to the thread, no. Admittedly, Ive only tried with a 4 gig card though.
Reply
4. Jameson says:
January 29, 2013 at 16:21
I have a 2 GB SD Card and 16 GB USB stick and got this working correctly after a few tries. 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: This is what I did:
1. On Windows format both your SD card and USB stick to FAT32. I did this through diskpart. 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. 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. 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. 4. Hook up your keyboard and monitor. Start your RPi up.
5. I selected to expand rootfs to the entire disk. Reboot. 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. 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 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 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 . something .
8. After that is done, run: sudo nano /boot/cmdline.txt 8. After that is done, run: sudo nano /boot/cmdline.txt
Change where it says root=/dev/mmcblk0p2 to /dev/sda1 Change where it says root=/dev/mmcblk0p2 to /dev/sda1
9. Next, run: sudo nano /etc/fstab 9. Next, run: sudo nano /etc/fstab
Change /dev/mmcblk0p2 to /dev/sda1 Change /dev/mmcblk0p2 to /dev/sda1
10. Reboot (sudo shutdown -r now). You should now be on your USB stick! Run df -h and youll be disappointed with the 10. Reboot (sudo shutdown -r now). You should now be on your USB stick! Run df -h and youll be disappointed with the
file size like I was >.< file size like I was >.<
11. Run sudo resize2fs /dev/sda1 11. Run sudo resize2fs /dev/sda1
This took about 30 minutes to finish executing. This took about 30 minutes to finish executing.
12. Restart if it doesn't automatically. Run df -h and see your full USB stick! 12. Restart if it doesn't automatically. Run df -h and see your full USB stick!
Reply
Jonathan says:
January 29, 2013 at 17:15
Thanks! This is a great contribution, since it shows how you got it working on Windows, then booting to the raspberry 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. pi, where I mainly copied stuff back and forth on my Mac with barely touching the Raspberry after boot.
Reply
Krzysztof Antoszek says:
March 11, 2013 at 19:18
+1 Jameson, worked like a charm, big thx! +1 Jameson, worked like a charm, big thx!
Reply
5. metaforest says:
February 15, 2013 at 10:03
Thanks Jameson and Jonathan for the great info for shuffling partitions around. Thanks Jameson and Jonathan for the great info for shuffling partitions around. I was able to transfer a living partition 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. from my SD card to an external USB HD and bring the whole thing back on line. Double plus thumbs up! Double plus thumbs up!
Reply
Jonathan says:
February 15, 2013 at 11:20
Glad you liked it, even with the 1984 reference ;D Glad you liked it, even with the 1984 reference ;D
Reply
6. zoel says:
March 13, 2013 at 00:45
thanx to Jameson and Jonathan for share your great info , but I used gparted to reformat mmcblk0p2 as swap partition 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 on sdcard and it done
Reply
7. eldingm says:
March 28, 2013 at 18:10
Boot Raspberry PI from a USB Stick - JonathanMH 12/11/2013
http://jonathanmh.com/boot-raspberry-pi-from-a-usb-stick/ 3 / 6
Tried it out. It worked first time. Thanks a million guys! Tried it out. It worked first time. Thanks a million guys!
Reply
8. flexnard says:
May 1, 2013 at 13:37
I wanted to do this very same thing with an External USB HD while I got it to finally work. 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 Their is still things you should
note (think about) before doing so. 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 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 HDs will not have any issues like this but, the port isnt putting the power out to keep spinning larger (self powered USB HDs will not have any issues like this but, the port isnt putting the power out to keep spinning larger
HDs) remember bigger space means more platters inside to spin. HDs) remember bigger space means more platters inside to spin. which ends up begging the question.. which ends up begging the question.. How much space How much space
do you really need (though over kill isnt always bad)? do you really need (though over kill isnt always bad)? my pi is specifically being used to back up one thing to its HD 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). (currently) a live Minecraft server off a VPS (twice a day). Since I wanted something very low power that I could simply Since I wanted something very low power that I could simply
leave on 24/7 but couldnt rely on SD cards (they tend to fail often because they where never designed to be used for this leave on 24/7 but couldnt 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. purpose/this often) I decided a HD was the right choice.
Final setup Setup: Final setup Setup:
RaspberryPi B-rev2 RaspberryPi B-rev2
Iocell laptop HD enclosure aka i-portable Iocell laptop HD enclosure aka i-portable
Seagate 5400 80 gig Momentus xt Seagate 5400 80 gig Momentus xt
Boot SD is an extremely old 256meg nothing special card I had laying around (cant even buy less then 2 gigs anymore Boot SD is an extremely old 256meg nothing special card I had laying around (cant even buy less then 2 gigs anymore
and even those are rare) made by Sandisk. and even those are rare) made by Sandisk.
setup attempt #1 (this didnt work): setup attempt #1 (this didnt work):
same as the final but with a WD Scorpio Blue HD (1TB) SATA2 power usage isnt listed, but I suspect its much like the HD same as the final but with a WD Scorpio Blue HD (1TB) SATA2 power usage isnt listed, but I suspect its much like the HD
below! below!
setup attempt #2 (still didnt work): setup attempt #2 (still didnt work):
same as the final but with a Hitachi 5400 I suspect its SATA2 but cant confirm (came out of the Apple Mac Mini mid same as the final but with a Hitachi 5400 I suspect its SATA2 but cant 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.. 2011) and is labeled as needing 700mA and 5v (I should of looked at the label first (live and learn.. Read those labels Read those labels
kids)! because its requires more then the Pi will give it! 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 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 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 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 why not get it to look better ). ).
you can see where Im going with it in this image: you can see where Im going with it in this image:
http://s21.postimg.org/3mk708ixj/pi_thoughts.jpg http://s21.postimg.org/3mk708ixj/pi_thoughts.jpg
when I get the new setup going Ill most likely have it doing more then just backing up Minecraft. when I get the new setup going Ill most likely have it doing more then just backing up Minecraft. Maybe severing files or Maybe severing files or
web server web server Ill figure that out later. Ill figure that out later.
Reply
Jonathan says:
May 1, 2013 at 20:16
Wow, you really put some effort into passing on your experience! Thank you so much! Im really really happy that this Wow, you really put some effort into passing on your experience! Thank you so much! Im really really happy that this
post I just wrote because I ran into problems, sparked off such exchange of experiences! post I just wrote because I ran into problems, sparked off such exchange of experiences!
Reply
9. Tom says:
June 2, 2013 at 19:20
This allowed me to boot despite only having a 156mb microSD card. Thanks! This allowed me to boot despite only having a 156mb microSD card. Thanks!
Reply
Jonathan says:
June 3, 2013 at 09:42
Thats pretty awesome! Its not like the card space is expensive these days, but why bother if you can do with this! Thats pretty awesome! Its not like the card space is expensive these days, but why bother if you can do with this!
Reply
10. Dannie Lamos says:
June 10, 2013 at 01:38
Hmm, cool stuff, seems a bit outdated but it works. Hopefully some of the Raspberry Pi stuff gets easier to do. Some crazy Hmm, cool stuff, seems a bit outdated but it works. Hopefully some of the Raspberry Pi stuff gets easier to do. Some crazy
projects projects
Reply
11. Raspberry PI, installing Arch Linux on USB drive | JonathanMH says:
June 20, 2013 at 11:15
Boot Raspberry PI from a USB Stick - JonathanMH 12/11/2013
http://jonathanmh.com/boot-raspberry-pi-from-a-usb-stick/ 4 / 6
[] guide is not going to differ a lot from the one I posted a while ago: Boot Raspberry PI from a USB stick, but in [] guide is not going to differ a lot from the one I posted a while ago: Boot Raspberry PI from a USB stick, but in
particular the parts of editing the cmdline.txt and growing the partition are a little [] particular the parts of editing the cmdline.txt and growing the partition are a little []
Reply
12. Search Engine Optimization for Images - JonathanMH says:
September 3, 2013 at 20:10
[] [] http://jonathanmh.com/boot-raspberry-pi-from-a-usb-stick/ http://jonathanmh.com/boot-raspberry-pi-from-a-usb-stick/ [] []
Reply
13. xbmcnut's Blog How To move your BOOT partition to a USB flash drive or external HDD under Xbian says:
October 1, 2013 at 20:52
[] support the boot process. What follows is how I achieved this. [] support the boot process. What follows is how I achieved this. First off, credit to @Jameson for this post which is First off, credit to @Jameson for this post which is
what all my effort was based on, thank you. But wait, before you get started and waste 30 [] what all my effort was based on, thank you. But wait, before you get started and waste 30 []
Reply
Leave a Reply
Name (required) Name (required)
Mail (will not be published) (required) Mail (will not be published) (required)
Website Website
Submit Comment Submit Comment

Submit Submit
last post: 2 days ago
GitLab Book
My GitLab Book has just been published! My GitLab Book has just been published!
Take a look: Take a look: GitLab Repository Management GitLab Repository Management
Categories
Blog
code
design
inspiration
music
photo
social media
software
statements
Boot Raspberry PI from a USB Stick - JonathanMH 12/11/2013
http://jonathanmh.com/boot-raspberry-pi-from-a-usb-stick/ 5 / 6
Work
Code
Design
Video
WordPress
comments
Running GitLab on Digital Ocean - JonathanMH on GitLab Repository Management published!
Jonathan on Best JavaScript MVC Frameworks 2013-2014
adi on Building Relations: On Giving Credit
Andrew on Best JavaScript MVC Frameworks 2013-2014
Checkit | Pearltrees on Installing and running node.js on Mac OS X
get in touch
twitter
rss feed
github
facebook
linkedin
Boot Raspberry PI from a USB Stick - JonathanMH 12/11/2013
http://jonathanmh.com/boot-raspberry-pi-from-a-usb-stick/ 6 / 6

You might also like