42

Is there a way to boot from an external hard drive connected to the device through the USB port (as opposed to booting from the SD card)?

7

Now, nearly five years later after author originally asked this question,
Raspberry Pi officially supports booting from USB mass storage device.

However, this is supported only for Raspberry Pi 3. Here's why:

Will it be possible to boot a Pi 1 or Pi 2 using MSD?

Unfortunately not. The boot code is stored in the BCM2837 device only, so the Pi 1, Pi 2, and Pi Zero will all require SD cards.

28

It is not possible to boot RPi from USB directly in the true sense of the word. However there's nothing to stop someone from making a mini-distro which would contain /boot and some kind of a boot manager. This could then implement booting from USB or even a PXE style environment. This could fit on a tiny SD card - 64MB cards are now available for pennies. I'm expecting that someone will roll a distribution for this - but haven't found one to date.

In the meanwhile you can move your own root partition onto hard disk to get faster boot times, but it's somewhat involved as you'll need to get a kernel that supports USB storage. Good instructions on how to do this can be found at: http://mitchtech.net/raspberry-pi-root-fs-on-usb-drive/

  • 3
    This is a good idea. – Jivings Jun 27 '12 at 9:04
  • Update: there is now experimental support for booting directly to USB; no sdcard required after the initial setup. – Hydraxan14 Jan 17 '17 at 22:27
21

From the Raspberry Pi FAQ:

You have to boot from SD but a USB HD can “take over” after the initial boot. You cannot boot without an SD card.

  • 1
    does that mean after the hardisk takes over then there is no need for the memory car anymore ? – Suhaib May 12 '13 at 22:02
5

Indeed, if you can live with just the SD MS-DOS partition (/boot) where the kernel reside, you can have /root and everything else on an external device. USB memory card or a physical hard drive are fine as secondary drive. The good thing is that unless you 'dd' to the wrong location, this is a non-destructive procedure: one edit and you go back to the original,

To setup this configuration is pretty easy. You configure your installation as usual and the move/copy the EXT4 partition to the external drive.

Using 'fdisk' partition your selected secondary drive, create a partition the same or larger size than your current mmcblk0p2 (or mmcblk0p5). Save the new configuration.

Find the partition name, in this sample, '/dev/sda5' however, this partition will depend on your configuration.

Copy the running partition (note: is not a good advisable to copy a running partition, some files are in 'unstable' or open state, however, work fine):

dd if=/dev/mmcblk0p2 of=/dev/sda5 bs=10M

now, edit the following line on the /boot/cmdline.txt file and modify the 'root' location:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

To this new line.

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/sda5 rootfstype=ext4 elevator=deadline rootwait

Note that the boot partition is MS-DOS, so if you have to fix you can mount the SD elsewhere and edit. If boot fails, the loader will show on your (HDMI) screen the available mounting points.

This setup is contingent to the mount order. The partition number may change if the device is mounted on another slot; you can make this location independent as follows.

Find the the device 'UUID'

blkid /dev/sda5
/dev/sda5: UUID="13d368bf-6dbf-4751-8ba1-88bed06bef77" TYPE="ext4"

or create a new one

tune2fs -U random /dev/sda5

and get the newly assigned name

blkid /dev/sda5
/dev/sda5: UUID="25b6aa72-ddc4-485e-8044-900ac24d662b" TYPE="ext4"

then edit the previously modified cmdline.txt changing the root location to:

root=UUID=25b6aa72-ddc4-485e-8044-900ac24d662b

After booting the new configuration, edit the fstab, remove the old /mmcblk0p2 note: This is a file will be on the 'new' /root device
Replace /dev/mmcblk0p% (% is the linux partition)

nano /etc/fstab
UUID=25b6aa72-ddc4-485e-8044-900ac24d662b ...
2

In raspbian, just change the root flag in /boot/cmdline.txt to root=/dev/sdaX where X is the number of the appropriate partition.

For details on how to get raspbian on your usb, etc, you can check here http://blog.krastanov.org/2014/01/30/booting-pi-reliably-from-usb/

1

I instead used windows for 100% of the creation.

I used (the free) 'MiniTool partition manager' and just transferred the boot to my smallest SD card, which can automatically be expanded with the partition manager. Open the cmdline.txt and change to root=/dev/sda5.

Same partition manager let me copy the ext4 to my portable 1TB (FYI remove all partitions from drives first so you have unpartitioned space before transferring). Vala - booted. I'm noticing with the standard HDD the access times are a bit lacking even though they have very fast R/W speeds compared to most SD cards.

Only issue I'm having now is expanding the ext4 (root) partition from the original 32GB (of my original SD card). So I only have 32GB of the 1TB currently. Hmm. I'm only a novice with the terminal and its commands so partitioning in linux is a bit flustering, but this guide helped VERY well.

  • Sorry, what guide? – Bex May 23 '16 at 6:54
  • Sorry, this forum. – Dave Jun 14 '16 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.