Booting a Raspberry Pi from a regular disk, avoiding the flaky SD card

; Date: August 7, 2017

Tags: Raspberry Pi

The Raspberry Pi is a cool little computer allowing you to do lots of crazy DIY projects interfaced through the GPIO port. While the Raspberry Pi is a small embeddable computer, because it runs Linux the Raspberry Pi is instantly approachable by any programmer. The biggest flaw in this picture is that it uses an SD card as the boot device. SD cards are not exactly fast nor reliable, preventing the Raspberry Pi from being used in serious production situations.

In April 2017 the Raspberry Pi foundation released the ability for the Raspberry Pi Model 3 to boot off a drive connected via USB. That instantly opens the door to using reliable regular disks rather than unreliable SD cards. The downside is that disks must connect via USB2 limiting disk throughput speed. As with anything there are plusses and minuses, but this is an interesting step forward.

For those seriously interested in using a Linux-Single-Board-Computer with a regular disk, some of the other devices will be a better choice. For example the Orange Pi Plus 2 has a SATA connector.

Raspberry Pi 3 Model B Motherboard
Raspberry Pi 3 Model B Motherboard:

Updating Raspbian

First, update your copy of Raspbian to the latest version. The feature was enabled in April 2017. Either, set up a brand new copy of Raspbian on an SD card, or else type in these commands on your existing Raspbian:

$ sudo apt-get update
$ sudo apt-get upgrade

With an up-to-date Raspbian on your Raspberry Pi, you can go to the next step.

Setting the boot mode in firmware

What we're going to do is enable a Raspberry Pi boot mode enabling the ability to boot off a "Mass Storage Device"

See:

The first thing is to run:

$ vcgencmd otp_dump | grep 17:

This queries the hardware registers for the boot mode. It will print a number other than 0x3020000a.

Next, edit /boot/config.txt and at the end of the file insert this line:

program_usb_boot_mode=1

When the Rapberry Pi is rebooted, this line rewrites the register queried above so that now the command should output:

$ vcgencmd otp_dump | grep 17:
17:3020000a

This enables the USB Mass Storage Device boot mode on that Raspberry Pi. From now on, that particular machine will boot either from SD card or USB MSD.

For good measure, remove the line from config.txt or else any Raspberry Pi booted by this SD card will gain that boot mode.

Prepare a USB drive

Put together an external USB drive case along with a drive of your choice. I know from experience you can power a laptop SATA drive in an external 2.5" drive case off the power available on a Raspberry Pi USB port. I used that for awhile to drive a larger disk on a Raspberry Pi.

Go to the Raspberry Pi downloads page - (www.raspberrypi.org) https://www.raspberrypi.org/downloads/

Download a copy of Raspbian.

Use your favorite method to "etch" the Raspbian onto the disk. The instructions on the Raspberry Pi website describe writing the Raspbian image to an SD card. You'll have to adjust the instructions because you're instead writing to an USB disk.

The easiest method is to use Etcher ( (etcher.io) https://etcher.io) since that application made the process so danged easy. One picky detail is that Etcher won't, by default, let you choose a USB drive because it only shows removable drives. However, in the Etcher settings is a checkbox for an unsafe mode that WILL let you install Raspbian onto a non-removable drive. Set that setting, and now your USB drive should show up, and you can then copy Raspbian to that drive.

Once Raspbian is on your USB drive, simply connect it to the Raspberry Pi. Remove the SD card, and then boot the computer.

If all went right, Raspbian will boot even though you do not have an SD card.