Raspberry PI – Boot from USB drive or stick

Problem

  • You want to use a USB drive or stick to store the OS and user data because it is more reliable than a normal SD card.
  • You only have a Windows based computer

Solution

The Raspberry can not boot from USB, but it is possible to transfer the root to the USB drive.

The solution consists of 4 steps:

  1. Extract the image from the SD-Card
  2. Copy image on USB drive/stick
  3. Change boot.txt
  4. Delete old root partition

Step 1

Install and configure the OS (Raspbian). After you finished this, remove the SD card from the Raspberry and insert it into your windows computer.

To extract the image from the SD, i used Win32 Disk Imager (Download). It can extract and write images. Just store the image on your hard disk.

disk imager

Step 2

Use the Win32 Disk Imager to write the image to the USB drive. After that, you have two different drives with the identical partition layout.

Step 3

Insert SD card and plug the USB drive in the Raspberry PI. With blkid you see the two identical layout of both disks. mmcblk0p is the SD card, sda the USB drive.

/dev/mmcblk0p1: SEC_TYPE=”msdos” LABEL=”RECOVERY” UUID=”47BE-8134″ TYPE=”vfat” PARTUUID=”000709f6-01″
/dev/mmcblk0p5: LABEL=”SETTINGS” UUID=”4b288679-4f9e-47bc-b72e-5989629d5e7f” TYPE=”ext4″ PARTUUID=”000709f6-05″
/dev/mmcblk0p6: SEC_TYPE=”msdos” LABEL=”boot” UUID=”67B4-B99A” TYPE=”vfat” PARTUUID=”000709f6-06″
/dev/mmcblk0p7: LABEL=”root” UUID=”0b00e3d6-6726-4db3-845d-335e3c5b548e” TYPE=”ext4″ PARTUUID=”000709f6-07″
/dev/sda1: SEC_TYPE=”msdos” LABEL=”RECOVERY” UUID=”47BE-8134″ TYPE=”vfat” PARTUUID=”000709f6-01″
/dev/sda5: LABEL=”SETTINGS” UUID=”4b288679-4f9e-47bc-b72e-5989629d5e7f” TYPE=”ext4″ PARTUUID=”000709f6-05″
/dev/sda6: SEC_TYPE=”msdos” LABEL=”boot” UUID=”67B4-B99A” TYPE=”vfat” PARTUUID=”000709f6-06″
/dev/sda7: LABEL=”root” UUID=”0b00e3d6-6726-4db3-845d-335e3c5b548e” TYPE=”ext4″ PARTUUID=”000709f6-07″

The interesting partition is the root partition. We have to tell the boot system, where the new root partition is located. Get the PARTUUID from the root partition (here from sda7): PARTUUID=”000709f6-07″

Open the /boot/cmdline.txt and change the root like this:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=PARTUUID=000709f6-07 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Step 4

If you would reboot now, the Raspberry would mount the SD card root to / because it’s the first partition he finds with the given ID. Thus you have to delete the old root partition.

For this i used gparted. You also can use fdisk like in this tutorial.

Step 5

Reboot

Fin

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s