HOW TO - Raspberry Pi3 boot from SSD - Install openHAB to USB or SSD and boot

Tags: #<Tag:0x00007f875c39b6e8> #<Tag:0x00007f875c39b5a8> #<Tag:0x00007f875c39b468>

(Gadget Guy) #1

I have been running openHAB for about 2 years and have suffered 2 SD card failures. The first card lasted about 14 months and the next only about 7 months or so. During these situations I got burned a bit with backup/restore and so I decided to install on a SSD hard drive for better reliability.

I am currently documenting the process for installing latest openhabian image onto a USB drive and set my Raspberry Pi 3b to boot from USB. (Without needing to use a card in the sd card slot (not even for /boot)


  • Main Computer - Linux - Ubuntu (or you can use Windows and Putty to execute commands over ssh)
  • Hardware running openhab2 (Raspberry Pi 3b)

Pre step: . From main computer, use ETCHER to flash latest openhabian image to micro SD card and follow initial setup. ssh into raspberry pi (can watch the install) - You can skip this step if you already have access to the running raspberryPi…

First, check status of current value for option to boot_From_USB in the OTP (one-time programmable memory) of the pi.

openhabian@openHABianPi:~$ vcgencmd otp_dump | grep 17:

The goal is to see a value of: 17:3020000a If you see this value, you can skip the next steps (your Pi already has this set and will attempt to boot from USB in the absence of sd card)

To enable USB boot mode, type the following:

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:

sudo reboot now

Once the Pi boots, it will read the new line from the /boot/config.txt file and enable the BOOT_FROM_USB option in the OTP memory. We should now see a value of 17:3020000a if set successfully, we can check again with the code:

$ vcgencmd otp_dump | grep 17:

You should see the new value of 17:3020000a which means the rpi will now check USB slots for bootable medium if one is not found in the memory card slot. (This is a permanent setting). You can now remove the last line from your /boot/config.txt file which we set above. (program_usb_boot_mode=1)

We can now shut down the raspberry pi and remove the SD card and insert our USB stick which has a new image of openhabian flashed using ETCHER.

sudo shutdown now

Remove SD card and plug in your USB now. unplug and re-plug the power adapter to your Pi. This initiate the first time boot from the USB stick or SSD drive.

After about 30 seconds you can watch the installation over ssh from your host computer by logging into the pi with:

ssh openhabian@x.x.x.x  

(default pass = openhabian) where x.x.x.x is the local IP address of your raspberry pi. This setup will take about 30-60 minutes.

Update: Dec 26th. Shortly after writing this, I decided to use a 240GB SSD. I followed the same process above and had absolutely no trouble. I used a powered USB adapter (as suggested below) with my drive inside the enclosure. This has been working great for a couple of weeks.

I hope you find this helpful.

Further Reading:
Raspberry Pi 3- Configure to boot from USB via OTP

Be sure to use a fast USB stick…(or better, use a Solid State Hard Drive - SSD)

I tried to follow this using a USB stick and it took over 2 hours and then finally failed on one of the last steps (updating openhab to latest stable). It seems to be writing much slower and I decided to abort… I came across a website with benchmark results… tuns out this one get a “terrible average bench” … I am using a 64GB Kingston DataTraveler 100 G3… So take note, and you may want to find a faster card!

USB Benchmark Results - Terrible Average Bench

(Kim Andersen) #3

I havn´t tried. But I wonder if you could write the image directly to an SSD and then boot I thin it should be possible if you have en Rpi3B+ since it can boot from USB by default.

(Patrick Beard) #4

I just did this last week with a 120GB SSD and my Raspberry Pi 3

Below is how I did it. It is not meant to be a tutorial and I take no responsibility for any omisions or errors!

I imaged my SD card with WinDisk32Imager. I then set the write once bit by adding program_usb_boot_mode=1 to the bottom of /boot/config.txt on the SD card. Then I rebooted to allow the bit to be written.

I then used Etcher to write the SD image I created to my 120GB SSD.

I removed the SD card from my RPi and connected the SSD using a powered SATA to USB lead.

Once it booted I sshd to the RPi and expanded the file system using the command line as raspi-config can’t do it with SSDs. To do this I did the following;

The commands below suited my SD image but may not suite yours

sudo fdisk /dev/sda

Enter p to see the partitions - take a note of the start of partition 2
Press d and then 2 to delete the main partition (I didn’t have a swap partition so nothing else to delete)
Press n then p and then 2 to create a new primary partition, next you need to enter the start of the partition by entering the start number from the old partition that you noted in step one.
For the end of the partition just press enter to accept the default.

If asked to remove ext4 signature select no.

If you are sure you have done everthing ok press w to write the new partition table.


ssh back in and enter sudo resize2fs /dev/sda2

When finished check using df -h.

The SSD and cable I used are;

Kingston 120GB SSD
Powered SATA to USB

(Gadget Guy) #5

That is a neat cable! Thanks for sharing.

Perhaps my issues are indeed are indeed power related… I will look into trying this type of powered USB cable.

I am using a 2.5A power supply to run the Pi and had previously mounted this drive and test creating a couple of files so I thought that might suggest I would be okay.

I am currently running off of SD card but will try again over the holidays to get the SSD based installation running. Will update this post once I do so.

(Patrick Beard) #6

I am also using a 2.5A psu. After my RPi failed to boot with the SSD I left it connected but booted from SD card. I could see the SSD details in the syslog so it was being seen. I never tried to mount it.

With the powered SATA to usb the Pi booted with no problem.

(Peter Loron) #7

Note that I have had success in writing the openhabian image directly to the SSD, rather than needing to use the microSD first.

(Kim Andersen) #8


(Peter Loron) #9

I had the SSD in an external USB case. I simply plugged that into my computer, and used Etcher to write the image to that disk. You need to go into settings and enable “unsafe mode” to be able to select non-flash media.

(Gadget Guy) #10

Yep - this is how I did it as well. checking “unsafe mode” was the key step.

Just be careful not to overwrite your existing hard drive!!! I had to triple check as my SSD was the same as the one running my rig!

(Kim Andersen) #11

Ahh okay… I use Win32DiskImager… Maybe thats the reason I couldn´t get it to work.

(Gadget Guy) #12

Okay, so i picked up a powered SATA to USB connector and sure enough everything worked great.

I had flashed the image using Etcher and it booted and installed without any problems. Will work on updating this tutorial. Thank you for getting me over this hump!

(Patrick Beard) #13

Did you remember to expand the file system?

(CM6.5 H102) #14

Just to give more options.:grinning:

I’ve been running my RPI on SSD without SD card for a while now. If you prefer to use something other than a powered adapter this works very well with the RPI.

(Gadget Guy) #15

Thanks - I first bought this exact one, but could not seem to get it to boot. Though, looking back it could have been user error as in earlier testing I was able to read and write files to the drive using that enclosure and cable.

(Gadget Guy) #16

The file system appears to have been resized automatically on first boot. (I used openhabian)

(Marijn Oudijk) #17

I’m going down this road to after my regular SD-card is showing strange behaviour again.
Any tips how to partition the SSD drive?
I’m coming from a 8gig SD_card and now I’ll have a 60gig SSD drive available. What’s the best practise in using different partitions? A ‘small’ root partition and a huge one for the data?

(CM6.5 H102) #18

If your planning to flash the openhabian image to the SSD via Etcher then you won’t need to partition the SSD it will work out of the box like the SD card.

If you plan to partition the drive then yes use a small partition for the boot and partition the rest however you like.