Boot from USB stick?


45 posts   Page 1 of 2   1, 2
by srynoname » Sat Jul 21, 2012 11:35 am
Hello,

I'd like to boot from a USB stick or lets say boot from SD card and then run from usb stick. What's the easiest and prefererred way to do this?

Thanks for any hint!
Posts: 23
Joined: Tue Jun 12, 2012 3:50 pm
by joan » Sat Jul 21, 2012 11:51 am
The boot code is read from the sd card so you can't boot from usb stick.
User avatar
Posts: 5482
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by srynoname » Sat Jul 21, 2012 11:56 am
thank you joan, I understand this. It's enough for me if then the root file system and so on is on the usb stick, so let pi boot from sd card and then let the stick take over. What's the best way to set this up?
Posts: 23
Joined: Tue Jun 12, 2012 3:50 pm
by joan » Sat Jul 21, 2012 12:11 pm
I have no idea.

Might be worthwhile to look through the following sort of thread.

http://raspberrypi.org/phpBB3/viewtopic.php?f=63&t=6685
User avatar
Posts: 5482
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by dom » Sat Jul 21, 2012 12:15 pm
Use dd or winimage to write the image to the USB stick rather than the sdcard.
Format the sdcard as FAT and copy the files from the FAT partition of the USB stick onto the sdcard (only needs to be about 64M in size).

Change cmdline.txt on sdcard from root=/dev/mmcblk0p2 to root=/dev/sda2
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4013
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Mr.Dave » Sat Jul 21, 2012 12:18 pm
dom wrote:Use dd or winimage to write the image to the USB stick rather than the sdcard.
Format the sdcard as FAT and copy the files from the FAT partition of the USB stick onto the sdcard (only needs to be about 64M in size).

Change cmdline.txt on sdcard from root=/dev/mmcblk0p2 to root=/dev/sda2



Could this also be used with a USB HDD of any size too or does the FS have to be FAT ?

(Still waiting for my Pi to arrive so picking up tips until then :) )
User avatar
Posts: 148
Joined: Sat Jun 30, 2012 6:59 pm
by srynoname » Sat Jul 21, 2012 12:43 pm
dom wrote:Use dd or winimage to write the image to the USB stick rather than the sdcard.
Format the sdcard as FAT and copy the files from the FAT partition of the USB stick onto the sdcard (only needs to be about 64M in size).

Change cmdline.txt on sdcard from root=/dev/mmcblk0p2 to root=/dev/sda2

Works awesome and without fiddlign, perfect, thank you!
Just one problem: raspi-config can't resize the root partition in this case ): Well, gues I have to do this manually or is there an easy way to fix the problem with raspi-config? Thanks :-)

Could this also be used with a USB HDD of any size too or does the FS have to be FAT ?

you need to initially boot from the SD card, then the external hdd can take over. FAT only required for the boot partition, for the root ext4 seems to be default.
Last edited by srynoname on Sat Jul 21, 2012 1:05 pm, edited 1 time in total.
Posts: 23
Joined: Tue Jun 12, 2012 3:50 pm
by Mr.Dave » Sat Jul 21, 2012 1:02 pm
srynoname wrote:
dom wrote:Use dd or winimage to write the image to the USB stick rather than the sdcard.
Format the sdcard as FAT and copy the files from the FAT partition of the USB stick onto the sdcard (only needs to be about 64M in size).

Change cmdline.txt on sdcard from root=/dev/mmcblk0p2 to root=/dev/sda2

Works awesome and without fiddlign, perfect, thank you!
Just one problem: raspi-config can't resize the root partition in this case ): Well, gues I have to do this manually or is there an easy way to fix the problem with raspi-config? Thanks :-)

Could this also be used with a USB HDD of any size too or does the FS have to be FAT ?[/quoite]
you need to initially boot fromt he SD card, then the external hdd can take over. FAt only required for the boot partition, for the root ext4 seems to be default.



Great thanks alot :)
User avatar
Posts: 148
Joined: Sat Jun 30, 2012 6:59 pm
by dom » Sat Jul 21, 2012 1:05 pm
srynoname wrote:Works awesome and without fiddlign, perfect, thank you!
Just one problem: raspi-config can't resize the root partition in this case ): Well, gues I have to do this manually or is there an easy way to fix the problem with raspi-config? Thanks :-)


Try:
Code: Select all
cp /usr/bin/raspi-config ~
sed -i 's/mmcblk0p2/sda2/' ~/raspi-config                                                                             
sed -i 's/mmcblk0/sda/' ~/raspi-config
sudo ~/raspi-config


Then choose the resize root partition. Not tested this version, but I did something similar in the past.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4013
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by srynoname » Sat Jul 21, 2012 1:06 pm
srynoname wrote:
dom wrote:Use dd or winimage to write the image to the USB stick rather than the sdcard.
Format the sdcard as FAT and copy the files from the FAT partition of the USB stick onto the sdcard (only needs to be about 64M in size).

Change cmdline.txt on sdcard from root=/dev/mmcblk0p2 to root=/dev/sda2

Works awesome and without fiddlign, perfect, thank you!
Just one problem: raspi-config can't resize the root partition in this case ): Well, gues I have to do this manually or is there an easy way to fix the problem with raspi-config? Thanks :-)


Hmm about the resize, guess one could also put image on sd card completely, boot once, resize partition and then image the sd card, copy image to usb stick, clear sd card and put only boot stuff on it.

Edit: doms way also sounds quite well, will test it later. I forgot raspi-config is a script, not a binary application ;-)
Posts: 23
Joined: Tue Jun 12, 2012 3:50 pm
by Joe Schmoe » Sat Jul 21, 2012 1:34 pm
srynoname wrote:Edit: doms way also sounds quite well, will test it later. I forgot raspi-config is a script, not a binary application ;-)


The method should work just as well (well, almost) if it was a binary...

P.S. You could reduce the sed to a single invocation, like this:

sed -E 's/mmcblk0p?/sda/'
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2617
Joined: Sun Jan 15, 2012 1:11 pm
by srynoname » Sat Jul 21, 2012 1:42 pm
thank you both, tried it with doms "original commands" and it worked fine!
Posts: 23
Joined: Tue Jun 12, 2012 3:50 pm
by dom » Sat Jul 21, 2012 1:46 pm
Joe Schmoe wrote:P.S. You could reduce the sed to a single invocation, like this:

sed -E 's/mmcblk0p?/sda/'


No, the second replace doesn't have the p in. (Although I'm sure there exists a single line version).
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4013
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by kadamski » Sat Jul 21, 2012 3:00 pm
Actually Joes version will replace mmcblk0 to sda and mmcblk0p2 to sda2 in one line. It will also replace mmcblk0p1 to sda1 and so on.
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm
by dom » Sat Jul 21, 2012 3:34 pm
kadamski wrote:Actually Joes version will replace mmcblk0 to sda and mmcblk0p2 to sda2 in one line. It will also replace mmcblk0p1 to sda1 and so on.

You are quite right.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4013
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Joe Schmoe » Sat Jul 21, 2012 6:44 pm
Yes. "man re_format" should tell you all about these things.
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2617
Joined: Sun Jan 15, 2012 1:11 pm
by kermitas » Thu Aug 16, 2012 12:11 am
dom wrote:Use dd or winimage to write the image to the USB stick rather than the sdcard.
Format the sdcard as FAT and copy the files from the FAT partition of the USB stick onto the sdcard (only needs to be about 64M in size).

Change cmdline.txt on sdcard from root=/dev/mmcblk0p2 to root=/dev/sda2


Thank you 'dom'.
I was very easy to boot from SD card and then operate from pendrive:).

So now I have added sdhci-bcm2708.missing_status=0 sdhci-bcm2708.sync_after_dma=0 and started long term tests to see if different webcams works more stable with rpi.

I hope that SD card is now only used for boot and system will not turn randomly to read-only - on SD card IO errors. Am I right?
Posts: 108
Joined: Thu Jan 26, 2012 11:49 am
by MrWareWolf » Fri Mar 22, 2013 10:06 am
Sadly, I can't get this to work.

I followed the directions, but I get a kernel panic.

When I make a new NORMAL sd card the cmdline.txt contains this:
dwc_otg.speed=0 dwc_otg.lpm_enable=0 root=/dev/ram0 init=/sbin/init console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1

Do I need to let it completely install to sd card (including all the network updates and all that), & then mod the cmdline file..then make the usb go thru the whole network updates and all that again??
Posts: 6
Joined: Thu Dec 06, 2012 6:55 am
by RaTTuS » Fri Mar 22, 2013 10:24 am
MrWareWolf wrote:Sadly, I can't get this to work.

I followed the directions, but I get a kernel panic.

When I make a new NORMAL sd card the cmdline.txt contains this:
dwc_otg.speed=0 dwc_otg.lpm_enable=0 root=/dev/ram0 init=/sbin/init console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1

Do I need to let it completely install to sd card (including all the network updates and all that), & then mod the cmdline file..then make the usb go thru the whole network updates and all that again??

there are plenty of other posts about moving the rootfs
but basically
take a working SD card
and a blank USB drive [flash or HD]
duplicate the 2nd partition on the SD card to a partition on the USB drive
i.e.
dd bs=1M conv=sync,noerror if=/dev/mmcblk0p2 of=/dev/sda1
^ alter your if and of to whatever is correct for you
edit
/boot/cmdline.txt to be
dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 elevator=deadline rootwait
[alter what is /dev/mmcblk0p2 to be /dev/sda1or what your new drive is it will not be
root=/dev/ram0
]
reboot and your away

also
viewtopic.php?f=66&t=10998
Last edited by RaTTuS on Fri Mar 22, 2013 12:30 pm, edited 1 time in total.
1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX - Prosliver FTW
"That's not right, the badgers have moved the goalposts."
User avatar
Posts: 5003
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
by duberry » Fri Mar 22, 2013 12:20 pm
any one know if someone posted instructions/info needed to boot from usb without sd card ?

i found this https://twitter.com/TeamRaspi/status/313721902906613760
Raspberry Pi Team ‏@TeamRaspi 18 Mar

Today I got the Raspberry Pi model A booting with no sdcard! It's booting its code from USB (from a model B!)
lend me your arms, fast as thunderbolts, for a pillow on my journey.
If the environment was a bank, would it be too big to fail
so long; and thanks for all the pi
User avatar
Posts: 380
Joined: Mon Jan 28, 2013 10:44 pm
Location: standing on a planet that's evolving. And revolving at nine hundred miles an hour
by dom » Fri Mar 22, 2013 1:26 pm
duberry wrote:any one know if someone posted instructions/info needed to boot from usb without sd card ?

i found this https://twitter.com/TeamRaspi/status/313721902906613760
Raspberry Pi Team ‏@TeamRaspi 18 Mar

Today I got the Raspberry Pi model A booting with no sdcard! It's booting its code from USB (from a model B!)


Note the following message:
you cannot boot from a mass storage device, only from a host (ie plug it into your PC and boot it directly). But it's still cool!
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4013
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Joe Schmoe » Fri Mar 22, 2013 2:04 pm
Dom,

Are you saying that there is (at least a little bit) some credence to the claim on twitter?

The CW has always been that, despite what anyone says, you can't boot the Pi w/o an SD card.

FWIW, not that I see any real utility in this idea (I'm in the "But isn't it cool?" camp), how would one go about booting the Pi from the USB port (connected to another PC)? (That is, if there is anything to this at all...)
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2617
Joined: Sun Jan 15, 2012 1:11 pm
by dom » Fri Mar 22, 2013 6:37 pm
Joe Schmoe wrote:Are you saying that there is (at least a little bit) some credence to the claim on twitter?

The CW has always been that, despite what anyone says, you can't boot the Pi w/o an SD card.

FWIW, not that I see any real utility in this idea (I'm in the "But isn't it cool?" camp), how would one go about booting the Pi from the USB port (connected to another PC)? (That is, if there is anything to this at all...)


That twitter post is Gordon (gsh), so is true.
The model A Raspberry Pi can be booted from a USB *host* (like a PC) running the correct software.
Not sure if this will prove useful to anyone yet.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4013
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by rpdom » Fri Mar 22, 2013 9:07 pm
If the model A could be booted from a PC (ideally a Debian Linux system) via USB, that could make some of the bare metal testing a lot less tedious without all the switching of the SD card. Just compile appropriate image on PC and boot Pi via USB.

I expect it wouldn't be worth the effort to set up for the few people who would use it though.
Posts: 3421
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by dindoun » Fri Dec 20, 2013 10:08 pm
Really great - it works -

the job I've done:
1. raspdebian on the sdcard
2. put the sd card and the usb stick formated in ext4 - 1 partition -in the computer ( linux )
it gives :
- /dev/sdb1 ( boot ) and /dev/sdb2 for the sd
- /dev/sdf1 on the usb stick
3. dd bs=1M conv=sync,noerror if=/dev/sdb2 of=/dev/sdf1 ; sync
4. change root=/dev/mmcbl... into root=/dev/sda1

CARE WITH THE POINT 3 : AFTER of= YOU MUST PUT THE PARTITION OF THE USB STICK - NO ERROR ALLOWED.
Posts: 1
Joined: Fri Dec 20, 2013 9:56 pm