Make Raspbian run from an external USB hard drive or USB memory stick

Raspberry Pi can ONLY boot from the SD Card. If you want to use your Raspberry Pi from an external USB hard drive or memory stick, either way have to install Raspbian in an SD Card an boot from it. You can see how to do it with Mac OS X in “Install Raspbian RAW image into an SD Card in Mac OS X“. Once you have Raspbian installed in the SD Card you have to do just the same in the USB hard drive or memory stick of your choice.

Plug-in the SD Card to your computer and edit the file cmdline.txt in the boot partition from this:

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

To this:

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

You only have to change the root option to boot from /dev/mmcblk0p2 to /dev/sda2.

Now you’ll boot from the SD Card but the boot system will load the system in the USB drive. That’s why we also installed Raspbian into it. Plug both the SD Card and the USB drive into your Raspberry Pi and boot normally.

raspi-config will show you all the options you can configure (enable SSH server, configure the timezone, etc.) but unfortunately it can’t resize USB drives so we’ll have to do it ourselves.

Run fdisk:

sudo fdisk /dev/sda

Press p to see the partitions. You’ll see something like this:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/sda2          122880     5785599     2831360   83  Linux

Write down the “Start” number in the /dev/sda2 partition because we’ll need that number when we define the new partition. In my case it is 122880. Press d and then 2 to delete that partition (don’t worry, the data on it won’t be deleted).

Create a new partition pressing n, press p for primary partition and then 2 for the partition number. When asked for the first sector use the number we writed down before (122880) and then when asked for the last sector just press enter. Finish the process pressing w to write the changes.

Reboot your Raspberry Pi:

sudo reboot

When Raspbian boots again the last step is to resize the partition:

sudo resize2fs /dev/sda2

Ref: http://www.dingleberrypi.com/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/

You might also like

TP-Link TL-WN725N version 2 in Raspberry Pi
Version 2 of TP-Link TL-WN725N driver doesn't come by default in Raspbian so it won't work by just plug-ining...
Compile, Install, Configure and make start on boot the noip.com client in Raspbian
First sign up for a no-ip account in http://www.noip.com/ and create a hostname for your Raspberry Pi. In...
Install Raspbian RAW image into an SD Card in Mac OS X
First download a Raspbian RAW image from here: http://www.raspberrypi.org/downloads Plug-in your SD...
Compile and install driver for TP-Link TL-WN725N version 2 in Raspbian
NOTICE! This module is now deprecated as for kernel >= 3.10.0. If you update with rpi-update the module...
Leave a comment ?

3 Comments.

  1. He seguido todos tus pasos, pero me pregunta después de crear una nueva partición, si la quiero 1 primaria, 0 extendida ó 3 libre. Cual debo poner? Muchas gracias

  2. Hello, I tried something like following your tutorial.
    I copied the entire contents of my sdcard to hd using dd, as (I think) is an exact copy of the sdcard I do not think there would be problems but it happens that whenever I edit the cmdline.txt to /dev/sda2, when I reboot the system does boot from sdcard and the cmdline changes to mmcblk0p2 again :/

    Have you any idea what it might be?
    (sorry my bad english, i’m Brazilian)

Reply to Davidson ¬
Cancel reply