Booting Raspberry Pi 3 (RPi3) from USB mass storage without sd card

Update December 2017:

This tutorial is outdated.
With newer version of Raspbian you can install an USB SSD the same way as a sd card.

A lot of openHAB users are concerned about the reliability of sd cards. Under certain circumstances while using persistence services and with a lot of read/write cycles through openHAB and system logging they tend to worn out.

For the RPi3 there is a new USB mass storage boot mode which allows to boot the operating system from a harddisk, preferable an SSD harddisk, without the need of any sd card at all. You just need a sd card once to setup the boot mode.
This will not work with older RPi1 or RPi2 models!
After successful setup completion the sd card is removed and is not needed any more to boot the system.

Note:
the new USB boot mode is provided through beta firmware and may not work with all USB harddisks.
More information and a general overview about the new boot modes can be found here:

https://www.raspberrypi.org/blog/pi-3-booting-part-i-usb-mass-storage-boot/

I tested it with two old noname USB flash drives (8GB and 16GB) and they both worked. I then bought a 128GB USB 3.0 SSD harddisk and since two month I‘m using this setup without any problems.

Setup:
Follow this tutorial exactly:

https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md

Note:
there is one step missing in that tutorial:
before entering the command
sudo mkfs.vfat -n BOOT -F 32 /dev/sda1
you have to exit parted with quit

Update: a plain sudo apt-get update && upgrade is sufficient now, see also:
https://www.raspberrypi.org/forums/viewtopic.php?p=1172476#p1172476
Note:
Because the new USB mass storage boot mode is provided through beta firmware you can‘t upgrade your system with
apt-get upgrade
anymore. This will disable the USB mass storage boot mode and you have to start from scratch again.


Solution for this:
rename file /boot/.firmware_revision to something else, f.e. old_.firmware_revision
perform
sudo apt-get update && sudo apt-get -y dist-upgrade && sudo BRANCH=next rpi-update
and voila, system and openHAB (if installed through apt-get) is up to date.

9 Likes

@sihui: When do I have to do this step? After preparing (and copy to) the ssd? Or before? Or after the removal of the sd and the first ssd boot? Or doesn’t it matter? And I have noticed that after the apt-get steps the .firmware_revision file is created again. Is that correct?

Before performing
sudo apt-get update && sudo apt-get -y dist-upgrade && sudo BRANCH=next rpi-update

Yes.

Addition: you only have to do this if you already have successfully prepared your ssd for USB boot and want to upgrade your operating system.
It’s not a step which has to be performed while first preparing and enabling the USB Boot mode.

Have fun.

Ok, thanks sihui. Got it up and running!

One last question: I think the boot sequence (until I can log in to ssh) now takes longer (perhaps 10 sec.?!). Even though I am using a SSD drive. Do you know if this is normal?

I never had openHAB2 running from sd, only from ssd, so I cannot tell …

I also have the impression that booting from an alternative device (e.g. USB stick) takes a bit longer, so I’m guessing it’s normal. I presume that it checks for other boot devices first (e.g. SD) and only boots from the USB stick after the appropriate timeout.

Steve

What does this command precisely? Everytime we need to upgrade the system we should use this command? Or this is one time only command?

According to this post it is not needed anymore:

https://www.raspberrypi.org/forums/viewtopic.php?p=1172476#p1172476

Haven’t tried it yet, though …

mhh
no USB Mode etc needs to be set anymore?
just burn the image to an USB ssd/hdd ?

You still need to set the usb bit, though:

https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md

Is it or will it be possible to move everything from SD card to USB SSD via the openhabian-config method or will that only move the data to the SSD and keep /boot on the SD card? I wouldn’t necessarily want to install from scratch.

Noone? Do I have to do a fresh install of everything to boot / run completely from SSD? Or is there a way to port a running installation from microSD to SSD (e.g. via openhabian-config feature to boot from USB)?

I’m no sure but when I did this a couple of weeks ago, I wasn’t sure whether my SD image was corrupt so I backed up my user-data and conf files and made a new image on the SSD card. It didn’t take long.

I copied the instructions from threads on here because I can never find anything easily a second time (so apologies for the plagarism).

Prepare SSD card

• Get new openHABian  …..img.zx  zip file to PC.
• Extract on PC using [7-ZIP.exe](	http://www.7-zip.org/)
http://www.7-zip.org/
• Copy file to SSD using Win32DiskImager (Etcher doesn't seem to see SSD card)

Prepare RPI
(one way process for PI to enable it to boot from SSD)

  • Stop openHAB service (if running)
sudo apt-get update && sudo apt-get upgrade

echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt

This adds program_usb_boot_mode=1 to the end of /boot/config.txt.
Reboot the Raspberry Pi with sudo reboot, then check that the OTP has been programmed:

vcgencmd otp_dump | grep 17:
17:3020000a
  • Ensure the output 0x3020000a is shown. If it is not, then the OTP bit has not been successfully programmed.

Remove the program_usb_boot_mode line from config.txt, so that if you put the SD card in another Raspberry Pi, it won’t program USB boot mode. Make sure there is no blank line at the end of config.txt. You can edit config.txt using the nano editor using the command sudo nano /boot/config.txt, for example.

  • Power down and remove SD card.
sudo shutdown -h now
  • Boot from SSD card

  • Copy back conf and user data files

  • Install any other stuff like Mosquitto (using openhabian)

If i set the bit to usb mode, then i can not boot this raspi 3 with a sdcard anymore? I only can use the sd-card as external drive for data storage, but never ever again for booting? Is this right?

So in other words the raspi gets “damaged” in any way (wrong word, but you know what i mean)?

No, although what you have set is OTP (One time programmable) so you can’t unset it, the Pi still goes through a boot sequence - first it looks for a SD card to boot from and then an external USB drive.

So, with no SSD or USB plugged in but with an SD card fitted, it should still boot from SD.

I’d try it with mine to confirm but I’m on a soak test and don’t want to switch it off!

@Saracen this is correct. Setting the OTP bit just alters boot flow. It does not disable SD card slot.

1 Like

I have set up a new system with a rpi3 B+ and a SSD.
I flashed the SSD with openhabian 2.3 image , conected it to the pi and started the system.
The installation was performed witout problems and the system is running.
OK to update the system in openhabian-config.
Have no errors in openhab log viewer but have noticed the following behavior on the pi:
The green status led repeatedly blinks fast 3 times make a pause of about 1 second and start over.
Is this a normal behavior or not?

Yep, just walked in and took a look, seems normal and it’s been running about a month w/ no issues.

Edit: And I have the same set up as you.

Thanks for your quick answer